Skip to content

Commit 903227d

Browse files
authored
Merge pull request #444 from callofduty4x/fix/build
fix: add explicit C/C++ standard, remove dead code
2 parents 75e1398 + 05cd9a1 commit 903227d

File tree

8 files changed

+7
-641
lines changed

8 files changed

+7
-641
lines changed

makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ CC=gcc
4545
CPP=g++
4646
WIN_DEFINES=WINVER=0x501
4747
LINUX_DEFINES=_GNU_SOURCE
48-
CFLAGS=-m32 -msse2 -mfpmath=sse -Wall -fno-omit-frame-pointer -fmax-errors=15
48+
COMMON_FLAGS=-m32 -msse2 -mfpmath=sse -Wall -fno-omit-frame-pointer -fmax-errors=15
49+
CFLAGS=$(COMMON_FLAGS) -std=gnu11
50+
CXXFLAGS=$(COMMON_FLAGS) -std=gnu++11
4951

5052
ifeq ($(DEBUG), true)
5153
DCFLAGS=-fno-pie -O0 -g
@@ -221,7 +223,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
221223
# -march=nocona
222224
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
223225
@echo $(CPP) $@
224-
@$(CPP) -c $(CFLAGS) $(DCFLAGS) $(C_DEFINES) -o $@ $<
226+
@$(CPP) -c $(CXXFLAGS) $(DCFLAGS) $(C_DEFINES) -o $@ $<
225227

226228
################################
227229
# A rule to build assemler code.

src/cm_local.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ cmodel_t *CM_ClipHandleToModel( clipHandle_t handle );
258258
extern clipMap_t cm;
259259
void __cdecl CM_LoadMapFromBsp(const char *name, char a2);
260260
void __cdecl CM_LoadStaticModels();
261-
void __cdecl DynEnt_LoadEntities();
261+
void __cdecl DynEnt_LoadEntities(const char *name);
262262

263263

264264

@@ -389,4 +389,4 @@ bool __cdecl Com_IsBspLoaded();
389389
#endif
390390

391391

392-
#endif
392+
#endif

src/common.c

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ cvar_t* com_maxFrameTime;
8080
cvar_t* com_animCheck;
8181
cvar_t* com_developer;
8282
cvar_t* useFastFile;
83-
cvar_t* com_developer;
8483
cvar_t* com_developer_script;
8584
cvar_t* com_logfile;
8685
cvar_t* com_sv_running;
@@ -126,40 +125,12 @@ typedef struct {
126125
} sysEvent_t;
127126

128127

129-
#define MAX_TIMEDEVENTARGS 8
130-
131-
typedef struct{
132-
universalArg_t arg;
133-
unsigned int size;
134-
}timedEventArg_t;
135-
136-
typedef timedEventArg_t timedEventArgs_t[MAX_TIMEDEVENTARGS];
137-
138-
139128
#define MAX_QUEUED_EVENTS 256
140-
#define MAX_TIMED_EVENTS 1024
141129
#define MASK_QUEUED_EVENTS ( MAX_QUEUED_EVENTS - 1 )
142-
#define MASK_TIMED_EVENTS ( MAX_TIMED_EVENTS - 1 )
143-
144-
typedef struct{
145-
int evTime, evTriggerTime;
146-
timedEventArgs_t evArguments;
147-
void (*evFunction)();
148-
}timedSysEvent_t;
149-
150130

151131
static sysEvent_t eventQueue[ MAX_QUEUED_EVENTS ];
152-
static timedSysEvent_t timedEventBuffer[ MAX_QUEUED_EVENTS ];
153132
static int eventHead = 0;
154133
static int eventTail = 0;
155-
static int timedEventHead = 0;
156-
157-
158-
void EventTimerTest(int time, int triggerTime, int value, char* s){
159-
160-
Com_Printf(CON_CHANNEL_SYSTEM,"^5Event exectuted: %i %i %i %i %s\n", time, triggerTime, Sys_Milliseconds(), value, s);
161-
162-
}
163134

164135
void CCS_InitConstantConfigStrings();
165136
void Com_ShutdownDObj();
@@ -183,101 +154,6 @@ void HunkAvailMemDebug()
183154
Com_Printf(CON_CHANNEL_CLIENT, "Hunk available: %d, Hunk total: %d\n", (s_hunkTotal - hunk_high.temp + hunk_low.temp) / (1024*1024), s_hunkTotal / (1024*1024));
184155
}
185156

186-
/*
187-
================
188-
Com_SetTimedEventCachelist
189-
190-
================
191-
*/
192-
void Com_MakeTimedEventArgCached(unsigned int index, unsigned int arg, unsigned int size){
193-
194-
if(index >= MAX_TIMED_EVENTS)
195-
Com_Error(ERR_FATAL, "Com_MakeTimedEventArgCached: Bad index: %d", index);
196-
197-
if(arg >= MAX_TIMEDEVENTARGS)
198-
Com_Error(ERR_FATAL, "Com_MakeTimedEventArgCached: Bad function argument number. Allowed range is 0 - %d arguments", MAX_TIMEDEVENTARGS);
199-
200-
timedSysEvent_t *ev = &timedEventBuffer[index];
201-
void *ptr = Z_Malloc(size);
202-
Com_Memcpy(ptr, ev->evArguments[arg].arg.p, size);
203-
ev->evArguments[arg].size = size;
204-
ev->evArguments[arg].arg.p = ptr;
205-
}
206-
207-
208-
/*
209-
================
210-
Com_AddTimedEvent
211-
212-
================
213-
*/
214-
int QDECL Com_AddTimedEvent( int delay, void *function, unsigned int argcount, ...)
215-
{
216-
timedSysEvent_t *ev;
217-
int index;
218-
int i;
219-
int time;
220-
int triggerTime;
221-
222-
if ( timedEventHead >= MAX_TIMED_EVENTS )
223-
{
224-
Com_PrintWarning(CON_CHANNEL_SYSTEM,"Com_AddTimedEvent: overflow - Lost one event\n");
225-
// we are discarding an event, but don't leak memory
226-
return -1;
227-
}
228-
229-
index = timedEventHead;
230-
231-
time = Sys_Milliseconds();
232-
233-
triggerTime = delay + time;
234-
235-
while(qtrue)
236-
{
237-
if(index > 0){
238-
239-
ev = &timedEventBuffer[index -1];
240-
241-
if(ev->evTriggerTime < triggerTime)
242-
{
243-
timedEventBuffer[index] = *ev;
244-
index--;
245-
continue;
246-
}
247-
}
248-
break;
249-
}
250-
251-
if(argcount > MAX_TIMEDEVENTARGS)
252-
{
253-
Com_Error(ERR_FATAL, "Com_AddTimedEvent: Bad number of function arguments. Allowed range is 0 - %d arguments", MAX_TIMEDEVENTARGS);
254-
return -1;
255-
}
256-
257-
ev = &timedEventBuffer[index];
258-
259-
va_list argptr;
260-
va_start(argptr, argcount);
261-
262-
for(i = 0; i < MAX_TIMEDEVENTARGS; i++)
263-
{
264-
if(i < argcount)
265-
ev->evArguments[i].arg = va_arg(argptr, universalArg_t);
266-
267-
ev->evArguments[i].size = 0;
268-
}
269-
270-
va_end(argptr);
271-
272-
ev->evTime = time;
273-
ev->evTriggerTime = triggerTime;
274-
ev->evFunction = function;
275-
timedEventHead++;
276-
return index;
277-
}
278-
279-
280-
281157
void Com_InitEventQueue()
282158
{
283159
// bk000306 - clear eventqueue
@@ -325,28 +201,6 @@ void Com_QueueEvent( int time, sysEventType_t type, int value, int value2, int p
325201
ev->evPtr = ptr;
326202
}
327203

328-
/*
329-
================
330-
Com_GetTimedEvent
331-
332-
================
333-
*/
334-
timedSysEvent_t* Com_GetTimedEvent( int time )
335-
{
336-
timedSysEvent_t *ev;
337-
338-
if(timedEventHead > 0)
339-
{
340-
ev = &timedEventBuffer[timedEventHead - 1];
341-
if(ev->evTriggerTime <= time)
342-
{
343-
timedEventHead--; //We have removed one event
344-
return ev;
345-
}
346-
}
347-
return NULL;
348-
}
349-
350204

351205
/*
352206
================
@@ -433,39 +287,6 @@ void Com_EventLoop( void ) {
433287
}
434288
}
435289

436-
437-
/*
438-
=================
439-
Com_TimedEventLoop
440-
=================
441-
*/
442-
void Com_TimedEventLoop( void ) {
443-
timedSysEvent_t *evt;
444-
int time = Sys_Milliseconds();
445-
int i;
446-
447-
while( qtrue ) {
448-
evt = Com_GetTimedEvent(time);
449-
450-
// if no more events are available
451-
if ( !evt ) {
452-
break;
453-
}
454-
//Execute the passed eventhandler
455-
if(evt->evFunction)
456-
evt->evFunction(evt->evArguments[0].arg, evt->evArguments[1].arg, evt->evArguments[2].arg, evt->evArguments[3].arg,
457-
evt->evArguments[4].arg, evt->evArguments[5].arg, evt->evArguments[6].arg, evt->evArguments[7].arg);
458-
459-
for(i = 0; i < MAX_TIMEDEVENTARGS; i++)
460-
{
461-
if(evt->evArguments[i].size > 0){
462-
Z_Free(evt->evArguments[i].arg.p);
463-
}
464-
}
465-
}
466-
}
467-
468-
469290
int Com_IsDeveloper()
470291
{
471292
if(com_developer && com_developer->integer)
@@ -1056,7 +877,6 @@ __optimize3 void Com_Frame( void ) {
1056877

1057878
PHandler_Event(PLUGINS_ONFRAME);
1058879

1059-
Com_TimedEventLoop();
1060880
Cbuf_Execute ( );
1061881
NET_Sleep(0);
1062882
NET_TcpServerPacketEventLoop();

0 commit comments

Comments
 (0)