Skip to content

Commit

Permalink
CLIENTONLY: Fix compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
meag committed Jun 25, 2017
1 parent 7ede912 commit bf94483
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 16 deletions.
4 changes: 3 additions & 1 deletion Makefile
Expand Up @@ -167,7 +167,9 @@ COMMON_OBJS := \
# temporary
SERVER_OBJS := \
pmove.o \
pmovetst.o \
pmovetst.o

SERVER_OBJS_REMOVED := \
pr_cmds.o \
pr_edict.o \
pr_exec.o \
Expand Down
6 changes: 6 additions & 0 deletions cl_demo.c
Expand Up @@ -2212,11 +2212,13 @@ static void CL_StopRecording (void)
//
void CL_Stop_f (void)
{
#ifndef CLIENTONLY
if (com_serveractive && strcmp(Cmd_Argv(0), "stop") == 0)
{
SV_MVDStop_f();
return;
}
#endif

if (!cls.demorecording)
{
Expand Down Expand Up @@ -2260,11 +2262,13 @@ void CL_Record_f (void)
{
char nameext[MAX_OSPATH * 2], name[MAX_OSPATH * 2];

#ifndef CLIENTONLY
if (com_serveractive && strcmp(Cmd_Argv(0), "record") == 0)
{
SV_MVD_Record_f();
return;
}
#endif

#if defined(PROTOCOL_VERSION_FTE) || defined(PROTOCOL_VERSION_FTE2)
if (cls.fteprotocolextensions &~ (FTE_PEXT_CHUNKEDDOWNLOADS|FTE_PEXT_256PACKETENTITIES))
Expand Down Expand Up @@ -2469,11 +2473,13 @@ void CL_EasyRecord_f (void)
{
char *name;

#ifndef CLIENTONLY
if ( com_serveractive )
{
SV_MVDEasyRecord_f();
return;
}
#endif

if (cls.state != ca_active)
{
Expand Down
6 changes: 6 additions & 0 deletions cl_main.c
Expand Up @@ -556,6 +556,7 @@ void CL_CheckForResend (void)
char data[2048];
double t1, t2;

#ifndef CLIENTONLY
if (cls.state == ca_disconnected && com_serveractive)
{
// if the local server is running and we are not, then connect
Expand Down Expand Up @@ -584,6 +585,7 @@ void CL_CheckForResend (void)
// FIXME: cls.state = ca_connecting so that we don't send the packet twice?
return;
}
#endif

if (cls.state != ca_disconnected || !connect_time)
return;
Expand Down Expand Up @@ -2276,8 +2278,10 @@ void CL_Frame (double time)
Cbuf_Execute();
CL_CheckAutoPause();

#ifndef CLIENTONLY
if (com_serveractive)
SV_Frame(cls.frametime);
#endif

// fetch results from server
CL_ReadPackets();
Expand Down Expand Up @@ -2321,8 +2325,10 @@ void CL_Frame (double time)
Cbuf_Execute();
CL_CheckAutoPause ();

#ifndef CLIENTONLY
if (com_serveractive)
SV_Frame (physframetime);
#endif

// Fetch results from server
CL_ReadPackets();
Expand Down
2 changes: 2 additions & 0 deletions cmodel.c
Expand Up @@ -1205,7 +1205,9 @@ cmodel_t *CM_LoadMap (char *name, qbool clientload, unsigned *checksum, unsigned

map_halflife = (i == HL_BSPVERSION);

#ifndef CLIENTONLY
Cvar_ForceSet (&sv_halflifebsp, i == HL_BSPVERSION ? "1" : "0");
#endif

// swap all the lumps
cmod_base = (byte *)header;
Expand Down
10 changes: 6 additions & 4 deletions com_msg.c
Expand Up @@ -318,8 +318,9 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *
//
// write the message
//
if (!to->number)
SV_Error ("Unset entity number");
if (!to->number) {
Sys_Error("Unset entity number");
}

#ifdef PROTOCOL_VERSION_FTE
if (to->number >= 512)
Expand All @@ -333,8 +334,9 @@ void MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t *

evenmorebits |= U_FTE_ENTITYDBL2;
required_extensions |= FTE_PEXT_ENTITYDBL2;
if (to->number >= 2048)
SV_Error ("Entity number >= 2048");
if (to->number >= 2048) {
Sys_Error("Entity number >= 2048");
}
}
else {
evenmorebits |= U_FTE_ENTITYDBL;
Expand Down
97 changes: 97 additions & 0 deletions common.c
Expand Up @@ -1575,6 +1575,103 @@ qbool COM_CheckArgsForPlayableFiles(char *commandbuf_out, unsigned int commandbu
return false;
}

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

static char q_normalize_chartbl[256];
static qbool q_normalize_chartbl_init;

static void Q_normalizetext_Init (void)
{
int i;

for (i = 0; i < 32; i++)
q_normalize_chartbl[i] = q_normalize_chartbl[i + 128] = '#';
for (i = 32; i < 128; i++)
q_normalize_chartbl[i] = q_normalize_chartbl[i + 128] = i;

// special cases
q_normalize_chartbl[10] = 10;
q_normalize_chartbl[13] = 13;

// dot
q_normalize_chartbl[5 ] = q_normalize_chartbl[14 ] = q_normalize_chartbl[15 ] = q_normalize_chartbl[28 ] = q_normalize_chartbl[46 ] = '.';
q_normalize_chartbl[5 + 128] = q_normalize_chartbl[14 + 128] = q_normalize_chartbl[15 + 128] = q_normalize_chartbl[28 + 128] = q_normalize_chartbl[46 + 128] = '.';

// numbers
for (i = 18; i < 28; i++)
q_normalize_chartbl[i] = q_normalize_chartbl[i + 128] = i + 30;

// brackets
q_normalize_chartbl[16] = q_normalize_chartbl[16 + 128]= '[';
q_normalize_chartbl[17] = q_normalize_chartbl[17 + 128] = ']';
q_normalize_chartbl[29] = q_normalize_chartbl[29 + 128] = q_normalize_chartbl[128] = '(';
q_normalize_chartbl[31] = q_normalize_chartbl[31 + 128] = q_normalize_chartbl[130] = ')';

// left arrow
q_normalize_chartbl[127] = '>';
// right arrow
q_normalize_chartbl[141] = '<';

// '='
q_normalize_chartbl[30] = q_normalize_chartbl[129] = q_normalize_chartbl[30 + 128] = '=';

q_normalize_chartbl_init = true;
}

/*
==================
Q_normalizetext
returns readable extended quake names
==================
*/
char *Q_normalizetext (char *str)
{
unsigned char *i;

if (!q_normalize_chartbl_init)
Q_normalizetext_Init();

for (i = (unsigned char*)str; *i; i++)
*i = q_normalize_chartbl[*i];
return str;
}

/*
==================
Q_redtext
returns extended quake names
==================
*/
unsigned char *Q_redtext (unsigned char *str)
{
unsigned char *i;
for (i = str; *i; i++)
if (*i > 32 && *i < 128)
*i |= 128;
return str;
}
//<-

/*
==================
Q_yelltext
returns extended quake names (yellow numbers)
==================
*/
unsigned char *Q_yelltext (unsigned char *str)
{
unsigned char *i;
for (i = str; *i; i++)
{
if (*i >= '0' && *i <= '9')
*i += 18 - '0';
else if (*i > 32 && *i < 128)
*i |= 128;
else if (*i == 13)
*i = ' ';
}
return str;
}

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

Expand Down
4 changes: 4 additions & 0 deletions config_manager.c
Expand Up @@ -451,11 +451,13 @@ static void DumpTeamplay(FILE *f)
TP_DumpTriggers(f);
}

#ifndef CLIENTONLY
void DumpFloodProtSettings(FILE *f)
{
extern int fp_messages, fp_persecond, fp_secondsdead;
fprintf(f, "floodprot %d %d %d\n", fp_messages, fp_persecond, fp_secondsdead);
}
#endif

void DumpMisc(FILE *f)
{
Expand All @@ -466,8 +468,10 @@ void DumpMisc(FILE *f)
DumpSkyGroups(f);
fprintf(f, "\n");

#ifndef CLIENTONLY
DumpFloodProtSettings(f);
fprintf(f, "\n");
#endif

fprintf(f, "hud_recalculate\n\n");

Expand Down
2 changes: 2 additions & 0 deletions host.c
Expand Up @@ -513,8 +513,10 @@ extern void LoadConfig_f(void);


//disconnect: fix it if i forgot something
#ifndef CLIENTONLY
Cmd_AddCommand ("floodprot", SV_Floodprot_f);
Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f);
#endif
Cmd_AddCommand ("msg_trigger", TP_MsgTrigger_f);
Cmd_AddCommand ("filter", TP_MsgFilter_f);
Cmd_AddCommand ("tp_took", TP_Took_f);
Expand Down
13 changes: 12 additions & 1 deletion menu.c
Expand Up @@ -925,7 +925,7 @@ void M_SinglePlayer_Draw (void) {
M_PrintWhite (88, 13*8, "Internet play only");
}

void M_SinglePlayer_Key (key) {
void M_SinglePlayer_Key (int key) {
switch (key) {
case K_BACKSPACE:
m_topmenu = m_none; // intentional fallthrough
Expand Down Expand Up @@ -1356,6 +1356,11 @@ void M_Draw (void) {
#ifndef CLIENTONLY
case m_load: M_Load_Draw (); break;
case m_save: M_Save_Draw (); break;
#else
// keeps gcc happy
case m_load:
case m_save:
break;
#endif
case m_multiplayer: Menu_MultiPlayer_Draw (); break;
case m_multiplayer_submenu: M_MultiPlayerSub_Draw(); break;
Expand Down Expand Up @@ -1416,6 +1421,10 @@ void M_Keydown (int key, wchar unichar) {
#ifndef CLIENTONLY
case m_load: M_Load_Key(key); return;
case m_save: M_Save_Key(key); return;
#else
case m_load:
case m_save:
break;
#endif
case m_multiplayer: Menu_MultiPlayer_Key(key, unichar); return;
case m_multiplayer_submenu: M_MultiPlayerSub_Key(key); return;
Expand Down Expand Up @@ -1445,7 +1454,9 @@ qbool Menu_Mouse_Event(const mouse_state_t* ms)
// functions should report if they handled the event or not
switch (m_state) {
case m_main: return M_Main_Mouse_Event(ms);
#ifndef CLIENTONLY
case m_singleplayer: return M_SinglePlayer_Mouse_Event(ms);
#endif
case m_multiplayer: return Menu_MultiPlayer_Mouse_Event(ms);
case m_multiplayer_submenu: return M_MultiPlayerSub_Mouse_Event(ms);
#ifndef CLIENTONLY
Expand Down
7 changes: 5 additions & 2 deletions menu_ingame.c
Expand Up @@ -143,7 +143,9 @@ setting botmatch_menu_entries[] = {

#define DEMOPLAYBACK() (cls.demoplayback && cls.mvdplayback != QTV_PLAYBACK)
#define BOTMATCH() (!strcmp(cls.gamedirfile, "fbca"))
#ifndef CLIENTONLY
#define SINGLEPLAYER() (com_serveractive && cls.state == ca_active && !cl.deathmatch && maxclients.value == 1)
#endif
#define QTVPLAYBACK() (cls.mvdplayback == QTV_PLAYBACK)

static settings_page *M_Ingame_Current(void) {
Expand All @@ -153,10 +155,11 @@ static settings_page *M_Ingame_Current(void) {
else if (BOTMATCH()) {
return &botmatch_menu;
}
else if (SINGLEPLAYER())
{
#ifndef CLIENTONLY
else if (SINGLEPLAYER()) {
return &single_menu;
}
#endif
else if (QTVPLAYBACK()) {
return &qtv_menu;
}
Expand Down
2 changes: 2 additions & 0 deletions net.c
Expand Up @@ -916,10 +916,12 @@ qbool NET_Sleep (int msec)
#endif

i = 0;
#ifndef CLIENTONLY
if (svs.socketip != INVALID_SOCKET) {
FD_SET(svs.socketip, &fdset); // network socket
i = svs.socketip;
}
#endif

timeout.tv_sec = msec/1000;
timeout.tv_usec = (msec%1000)*1000;
Expand Down
2 changes: 0 additions & 2 deletions pr2_exec.c
Expand Up @@ -65,8 +65,6 @@ void PR2_Init(void)
Cmd_AddCommand ("edictcount", ED_Count);
Cmd_AddCommand ("profile", PR2_Profile_f);
Cmd_AddCommand ("mod", PR2_GameConsoleCommand);

PR_CleanLogText_Init();
}

//===========================================================================
Expand Down
4 changes: 2 additions & 2 deletions sbar.c
Expand Up @@ -1111,10 +1111,10 @@ void Sbar_SoloScoreboard (void)

sprintf (str,"Secrets: %i/%i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
Sbar_DrawString (312 - strlen(str)*8, 12, str);

#ifndef CLIENTONLY
sprintf (str,"skill %i", (int)(skill.value + 0.5));
Sbar_DrawString (160 - strlen(str)*4, 12, str);

#endif
strlcpy(str, cl.levelname, sizeof(str));
strlcat(str, " (", sizeof(str));
strlcat(str, host_mapname.string, sizeof(str));
Expand Down
3 changes: 3 additions & 0 deletions server.h
Expand Up @@ -643,9 +643,12 @@ extern cvar_t maxclients;

extern cvar_t sv_specprint; //bliP: spectator print

#ifndef CLIENTONLY
extern server_static_t svs; // persistant server info
extern server_t sv; // local server
extern demo_t demo; // server demo struct
#endif

//extern entity_state_t cl_state_entities[MAX_CLIENTS][UPDATE_BACKUP][MAX_PACKET_ENTITIES]; // client entities

extern client_t *sv_client;
Expand Down
7 changes: 4 additions & 3 deletions sv_ccmds.c
Expand Up @@ -1942,9 +1942,10 @@ void SV_InitOperatorCommands (void)
Cmd_AddCommand ("gamedir", SV_Gamedir_f);
Cmd_AddCommand ("sv_gamedir", SV_Gamedir);

// qqshka: alredy registered at host.c
// Cmd_AddCommand ("floodprot", SV_Floodprot_f);
// Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f);
#ifdef CLIENTONLY
Cmd_AddCommand ("floodprot", SV_Floodprot_f);
Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f);
#endif

Cmd_AddCommand ("master_rcon_password", SV_MasterPassword_f);
/*
Expand Down
1 change: 0 additions & 1 deletion sv_init.c
Expand Up @@ -574,4 +574,3 @@ void SV_SpawnServer (char *mapname, qbool devmap)
SV_MVD_Record(NULL, true);
CL_ClearState ();
}

0 comments on commit bf94483

Please sign in to comment.