Skip to content

Commit

Permalink
source tree restructurization part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
BraXi committed Sep 9, 2024
1 parent d41b89d commit e2253c9
Show file tree
Hide file tree
Showing 34 changed files with 1,407 additions and 946 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the attached GNU General Public License v2 for more details.
// navigation.c - implementation of A* pathfinding alghoritm
// https://en.wikipedia.org/wiki/A*_search_algorithm

#include "qcommon.h"
#include "../qcommon/qcommon.h"

//#define DEBUG_PATHFINDING 1

Expand Down
4 changes: 2 additions & 2 deletions src/engine/win_input.c → src/engine/client/input_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ See the attached GNU General Public License v2 for more details.
// win_input.c -- windows 95 mouse code
// 02/21/97 JCB Added extended DirectInput code to support external controllers.

#include "client/client.h"
#include "../qcommon/pragma_windows.h"
#include "client.h"
#include "../../qcommon/pragma_windows.h"

extern unsigned sys_msg_time;

Expand Down
6 changes: 3 additions & 3 deletions src/engine/win_sound.c → src/engine/client/sound_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ See the attached GNU General Public License v2 for more details.

#include <float.h>

#include "client/client.h"
#include "client/snd_loc.h"
#include "../qcommon/pragma_windows.h"
#include "client.h"
#include "snd_loc.h"
#include "../../qcommon/pragma_windows.h"

#define iDirectSoundCreate(a,b,c) pDirectSoundCreate(a,b,c)

Expand Down
4 changes: 2 additions & 2 deletions src/engine/vid_dll.c → src/engine/client/vid_dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ See the attached GNU General Public License v2 for more details.
#include <assert.h>
#include <float.h>

#include "client/client.h"
#include "../qcommon/pragma_windows.h"
#include "client.h"
#include "../../qcommon/pragma_windows.h"

// Structure containing functions exported from refresh DLL
refexport_t re;
Expand Down
122 changes: 122 additions & 0 deletions src/engine/cmd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
pragma
Copyright (C) 2023-2024 BraXi.
Quake 2 Engine 'Id Tech 2'
Copyright (C) 1997-2001 Id Software, Inc.
See the attached GNU General Public License v2 for more details.
*/

/*
==============================================================
CMD - CONSOLE COMMANDS
Command text buffering and command execution
Any number of commands can be added in a frame, from several different sources.
Most commands come from either keybindings or console line input, but remote
servers can also send across commands and entire text files can be execed.
The + command line options are also added to the command buffer.
The game starts with a Cbuf_AddText ("exec quake.rc\n"); Cbuf_Execute ();
Command execution takes a null terminated string, breaks it into tokens,
then searches for a command or variable that matches the first token.
==============================================================
*/

#pragma once

#ifndef _PRAGMA_CMD_H_
#define _PRAGMA_CMD_H_

#define EXEC_NOW 0 // don't return until completed
#define EXEC_INSERT 1 // insert at current position, but don't run yet
#define EXEC_APPEND 2 // add to end of the command buffer

void Cbuf_Init(void);
// allocates an initial text buffer that will grow as needed

void Cbuf_AddText(char* text);
// as new commands are generated from the console or keybindings,
// the text is added to the end of the command buffer.

void Cbuf_InsertText(char* text);
// when a command wants to issue other commands immediately, the text is
// inserted at the beginning of the buffer, before any remaining unexecuted
// commands.

void Cbuf_ExecuteText(int exec_when, char* text);
// this can be used in place of either Cbuf_AddText or Cbuf_InsertText

void Cbuf_AddEarlyCommands(qboolean clear);
// adds all the +set commands from the command line

qboolean Cbuf_AddLateCommands(void);
// adds all the remaining + commands from the command line
// Returns true if any late commands were added, which
// will keep the demoloop from immediately starting

void Cbuf_Execute(void);
// Pulls off \n terminated lines of text from the command buffer and sends
// them through Cmd_ExecuteString. Stops when the buffer is empty.
// Normally called once per frame, but may be explicitly invoked.
// Do not call inside a command function!

void Cbuf_CopyToDefer(void);
void Cbuf_InsertFromDefer(void);
// These two functions are used to defer any pending commands while a map
// is being loaded

//===========================================================================

typedef void (*xcommand_t) (void);

void Cmd_Init(void);

void Cmd_AddCommand(char* cmd_name, xcommand_t function);
void Cmd_AddCommandCG(char* cmd_name, scr_func_t function);
// called by the init functions of other parts of the program to
// register commands and functions to call for them.
// The cmd_name is referenced later, so it should not be in temp memory
// if function is NULL, the command will be forwarded to the server
// as a clc_stringcmd instead of executed locally
void Cmd_RemoveCommand(char* cmd_name);
void Cmd_RemoveClientGameCommands();

qboolean Cmd_Exists(char* cmd_name);
// used by the cvar code to check for cvar / command name overlap

char* Cmd_CompleteCommand(char* partial);
// attempts to match a partial command for automatic command line completion
// returns NULL if nothing fits

int Cmd_Argc(void);
char* Cmd_Argv(int arg);
char* Cmd_Args(void);
// The functions that execute commands get their parameters with these
// functions. Cmd_Argv () will return an empty string, not a NULL
// if arg > argc, so string operations are always safe.

void Cmd_TokenizeString(char* text, qboolean macroExpand);
// Takes a null terminated string. Does not need to be /n terminated.
// breaks the string up into arg tokens.

void Cmd_ExecuteString(char* text);
// Parses a single line of text into arguments and tries to execute it
// as if it was typed at the console


#ifndef DEDICATED_ONLY
void Cmd_ForwardToServer(void);
// adds the current command line as a clc_stringcmd to the client message.
// things like godmode, noclip, etc, are commands directed to the server,
// so when they are typed in at the console, they will need to be forwarded.
#endif


#endif /*_PRAGMA_CMD_H_*/
70 changes: 70 additions & 0 deletions src/engine/cmodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
pragma
Copyright (C) 2023-2024 BraXi.
Quake 2 Engine 'Id Tech 2'
Copyright (C) 1997-2001 Id Software, Inc.
See the attached GNU General Public License v2 for more details.
*/


/*
==============================================================
COLLISION MODEL
==============================================================
*/

#pragma once

#ifndef _PRAGMA_CMODEL_H_
#define _PRAGMA_CMODEL_H_

void CM_FreeMap();
cmodel_t* CM_LoadMap(char* name, qboolean clientload, unsigned* checksum);
cmodel_t* CM_InlineModel(const char* name); // *1, *2, etc

int CM_NumClusters();
int CM_NumInlineModels();
char* CM_EntityString();

// creates a clipping hull for an arbitrary box
int CM_HeadnodeForBox(vec3_t mins, vec3_t maxs);


// returns an ORed contents mask
int CM_PointContents(vec3_t p, int headnode);
int CM_TransformedPointContents(vec3_t p, int headnode, vec3_t origin, vec3_t angles);

trace_t CM_BoxTrace(vec3_t start, vec3_t end,
vec3_t mins, vec3_t maxs,
int headnode, int brushmask);

trace_t CM_TransformedBoxTrace(vec3_t start, vec3_t end,
vec3_t mins, vec3_t maxs,
int headnode, int brushmask,
vec3_t origin, vec3_t angles);

byte* CM_ClusterPVS(int cluster);
byte* CM_ClusterPHS(int cluster);

int CM_PointLeafnum(vec3_t p);

// call with topnode set to the headnode, returns with topnode
// set to the first node that splits the box
int CM_BoxLeafnums(vec3_t mins, vec3_t maxs, int* list, int listsize, int* topnode);

int CM_LeafContents(int leafnum);
int CM_LeafCluster(int leafnum);
int CM_LeafArea(int leafnum);

void CM_SetAreaPortalState(int portalnum, qboolean open);
qboolean CM_AreasConnected(int area1, int area2);

int CM_WriteAreaBits(byte* buffer, int area);
qboolean CM_HeadnodeVisible(int headnode, byte* visbits);

void CM_WritePortalState(FILE* f);
void CM_ReadPortalState(FILE* f);

#endif /*_PRAGMA_CMODEL_H_*/
File renamed without changes.
83 changes: 83 additions & 0 deletions src/engine/cvar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
pragma
Copyright (C) 2023-2024 BraXi.
Quake 2 Engine 'Id Tech 2'
Copyright (C) 1997-2001 Id Software, Inc.
See the attached GNU General Public License v2 for more details.
*/

#pragma once

/*
==============================================================
CONSOLE VARIABLES
cvar_t variables are used to hold scalar or string variables that can be changed or displayed at the console or prog code as well as accessed directly
in C code.
The user can access cvars from the console in three ways:
r_draworder prints the current value
r_draworder 0 sets the current value to 0
set r_draworder 0 as above, but creates the cvar if not present
Cvars are restricted from having the same names as commands to keep this
interface from being ambiguous.
==============================================================
*/

#ifndef _PRAGMA_CVAR_H_
#define _PRAGMA_CVAR_H_

extern cvar_t* cvar_vars;

cvar_t* Cvar_Get(char* var_name, char* value, int flags, char* description);
// creates the variable if it doesn't exist, or returns the existing one
// if it exists, the value will not be changed, but flags will be ORed in
// that allows variables to be unarchived without needing bitflags

cvar_t* Cvar_Set(char* var_name, char* value);
// will create the variable if it doesn't exist

cvar_t* Cvar_ForceSet(char* var_name, char* value);
// will set the variable even if NOSET or LATCH

cvar_t* Cvar_FullSet(char* var_name, char* value, int flags, char* desc);

void Cvar_SetValue(char* var_name, float value);
// expands value to a string and calls Cvar_Set

float Cvar_VariableValue(char* var_name);
// returns 0 if not defined or non numeric

char* Cvar_VariableString(char* var_name);
// returns an empty string if not defined

char* Cvar_CompleteVariable(char* partial);
// attempts to match a partial variable name for command line completion
// returns NULL if nothing fits

void Cvar_GetLatchedVars(void);
// any CVAR_LATCHED variables that have been set will now take effect

qboolean Cvar_Command(void);
// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
// command. Returns true if the command was a variable reference that
// was handled. (print or change)

void Cvar_WriteVariables(char* path);
// appends lines containing "set variable value" for all variables
// with the archive flag set to true.

void Cvar_Init(void);

char* Cvar_Userinfo(void);
// returns an info string containing all the CVAR_USERINFO cvars

char* Cvar_Serverinfo(void);
// returns an info string containing all the CVAR_SERVERINFO cvars

extern qboolean userinfo_modified;
// this is set each time a CVAR_USERINFO variable is changed
// so that the client knows to send it to the server
#endif
11 changes: 3 additions & 8 deletions src/qcommon/filesystem.c → src/engine/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ Copyright (C) 1997-2001 Id Software, Inc.
See the attached GNU General Public License v2 for more details.
*/

#include "qcommon.h"
#include "../qcommon/qcommon.h"

// define this to dissalow any data but the demo pak file
//#define NO_ADDONS

// if a packfile directory differs from this, it is assumed to be hacked
#define PAK0_CHECKSUM 0x40e614e0

/*
=============================================================================
Expand Down Expand Up @@ -65,8 +60,8 @@ typedef struct searchpath_s
struct searchpath_s *next;
} searchpath_t;

searchpath_t *fs_searchpaths;
searchpath_t *fs_base_searchpaths; // without gamedirs
static searchpath_t *fs_searchpaths;
static searchpath_t *fs_base_searchpaths; // without gamedirs


/*
Expand Down
46 changes: 46 additions & 0 deletions src/engine/filesystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
pragma
Copyright (C) 2023-2024 BraXi.
Quake 2 Engine 'Id Tech 2'
Copyright (C) 1997-2001 Id Software, Inc.
See the attached GNU General Public License v2 for more details.
*/


/*
==============================================================
FILESYSTEM
==============================================================
*/

#pragma once

#ifndef _PRAGMA_FILESYSTEM_H_
#define _PRAGMA_FILESYSTEM_H_

void FS_InitFilesystem(void);
void FS_SetGamedir(char* dir);
char *FS_Gamedir(void);
char *FS_NextPath(char* prevpath);
void FS_ExecAutoexec(void);

int FS_FOpenFile(char* filename, FILE** file);
void FS_FCloseFile(FILE* f); // note: this can't be called from another DLL, due to MS libc issues


int FS_LoadFile(char* path, void** buffer);
// a null buffer will just return the file length without loading
// a -1 length is not present

void FS_Read(void* buffer, int len, FILE* f);
// properly handles partial reads

void FS_FreeFile(void* buffer);

int FS_LoadTextFile(char* filename, char** buffer);

void FS_CreatePath(char* path);

#endif /*_PRAGMA_FILESYSTEM_H_*/
File renamed without changes.
Loading

0 comments on commit e2253c9

Please sign in to comment.