From a7e02622ba4e82049f709eacc765256a69bcfecb Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Mon, 9 Mar 2009 16:37:47 +0000 Subject: [PATCH] OK, nun funktioniert CTF auch --- TODO | 3 - src/game/ctf/g_ctf.c | 4 +- src/game/ctf/g_spawn.c | 2 +- src/game/ctf/g_target.c | 4 +- src/game/ctf/p_client.c | 34 ++-- src/game/ctf/p_weapon.c | 2 +- src/game/ctf/q_shared.c | 435 +++++++--------------------------------- src/game/ctf/q_shared.h | 102 ++++------ 8 files changed, 137 insertions(+), 449 deletions(-) diff --git a/TODO b/TODO index cf1b9da0..09e6b483 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,9 @@ Kleine TODO-Liste: - Version und Identifikationsstring des Renderers anpassen -- Fehlerhafte Makros in g_local.h - QMAX nochmal sauber entfernen - WIN32 und sun aus dem Game entfernen - CTF, Rogue, Xatrix einfügen -- g_save in rogue und xatrix anpassen -- Im Spiel g_* und p_* gegen R1Q2 abgleichen - Nightmare im Menü freischalten - Spwanflags auch für Coop per Menü anpassbar machen diff --git a/src/game/ctf/g_ctf.c b/src/game/ctf/g_ctf.c index 6c07adb0..8315edf1 100644 --- a/src/game/ctf/g_ctf.c +++ b/src/game/ctf/g_ctf.c @@ -3220,10 +3220,10 @@ int CTFUpdateJoinMenu(edict_t *ent) } if (ctf_forcejoin->string && *ctf_forcejoin->string) { - if (stricmp(ctf_forcejoin->string, "red") == 0) { + if (Q_stricmp(ctf_forcejoin->string, "red") == 0) { joinmenu[jmenu_blue].text = NULL; joinmenu[jmenu_blue].SelectFunc = NULL; - } else if (stricmp(ctf_forcejoin->string, "blue") == 0) { + } else if (Q_stricmp(ctf_forcejoin->string, "blue") == 0) { joinmenu[jmenu_red].text = NULL; joinmenu[jmenu_red].SelectFunc = NULL; } diff --git a/src/game/ctf/g_spawn.c b/src/game/ctf/g_spawn.c index fe0b0217..aafbde11 100644 --- a/src/game/ctf/g_spawn.c +++ b/src/game/ctf/g_spawn.c @@ -589,7 +589,7 @@ void SpawnEntities (char *mapname, char *entities, char *spawnpoint) entities = ED_ParseEdict (entities, ent); // yet another map hack - if (!stricmp(level.mapname, "command") && !stricmp(ent->classname, "trigger_once") && !stricmp(ent->model, "*27")) + if (!Q_stricmp(level.mapname, "command") && !Q_stricmp(ent->classname, "trigger_once") && !Q_stricmp(ent->model, "*27")) ent->spawnflags &= ~SPAWNFLAG_NOT_HARD; // remove things (except the world) from different skill levels or deathmatch diff --git a/src/game/ctf/g_target.c b/src/game/ctf/g_target.c index 3296a247..ab048241 100644 --- a/src/game/ctf/g_target.c +++ b/src/game/ctf/g_target.c @@ -176,7 +176,7 @@ void SP_target_secret (edict_t *ent) ent->svflags = SVF_NOCLIENT; level.total_secrets++; // map bug hack - if (!stricmp(level.mapname, "mine3") && ent->s.origin[0] == 280 && ent->s.origin[1] == -2048 && ent->s.origin[2] == -624) + if (!Q_stricmp(level.mapname, "mine3") && ent->s.origin[0] == 280 && ent->s.origin[1] == -2048 && ent->s.origin[2] == -624) ent->message = "You have found a secret area."; } @@ -309,7 +309,7 @@ void SP_target_changelevel (edict_t *ent) } // ugly hack because *SOMEBODY* screwed up their map - if((stricmp(level.mapname, "fact1") == 0) && (stricmp(ent->map, "fact3") == 0)) + if((Q_stricmp(level.mapname, "fact1") == 0) && (Q_stricmp(ent->map, "fact3") == 0)) ent->map = "fact3$secret1"; ent->use = use_target_changelevel; diff --git a/src/game/ctf/p_client.c b/src/game/ctf/p_client.c index 366b72fb..cdd03088 100644 --- a/src/game/ctf/p_client.c +++ b/src/game/ctf/p_client.c @@ -51,7 +51,7 @@ static void SP_FixCoopSpots (edict_t *self) VectorSubtract(self->s.origin, spot->s.origin, d); if (VectorLength(d) < 384) { - if ((!self->targetname) || stricmp(self->targetname, spot->targetname) != 0) + if ((!self->targetname) || Q_stricmp(self->targetname, spot->targetname) != 0) { // gi.dprintf("FixCoopSpots changed %s at %s targetname from %s to %s\n", self->classname, vtos(self->s.origin), self->targetname, spot->targetname); self->targetname = spot->targetname; @@ -69,7 +69,7 @@ static void SP_CreateCoopSpots (edict_t *self) { edict_t *spot; - if(stricmp(level.mapname, "security") == 0) + if(Q_stricmp(level.mapname, "security") == 0) { spot = G_Spawn(); spot->classname = "info_player_coop"; @@ -107,7 +107,7 @@ void SP_info_player_start(edict_t *self) { if (!coop->value) return; - if(stricmp(level.mapname, "security") == 0) + if(Q_stricmp(level.mapname, "security") == 0) { // invoke one of our gross, ugly, disgusting hacks self->think = SP_CreateCoopSpots; @@ -140,20 +140,20 @@ void SP_info_player_coop(edict_t *self) return; } - if((stricmp(level.mapname, "jail2") == 0) || - (stricmp(level.mapname, "jail4") == 0) || - (stricmp(level.mapname, "mine1") == 0) || - (stricmp(level.mapname, "mine2") == 0) || - (stricmp(level.mapname, "mine3") == 0) || - (stricmp(level.mapname, "mine4") == 0) || - (stricmp(level.mapname, "lab") == 0) || - (stricmp(level.mapname, "boss1") == 0) || - (stricmp(level.mapname, "fact3") == 0) || - (stricmp(level.mapname, "biggun") == 0) || - (stricmp(level.mapname, "space") == 0) || - (stricmp(level.mapname, "command") == 0) || - (stricmp(level.mapname, "power2") == 0) || - (stricmp(level.mapname, "strike") == 0)) + if((Q_stricmp(level.mapname, "jail2") == 0) || + (Q_stricmp(level.mapname, "jail4") == 0) || + (Q_stricmp(level.mapname, "mine1") == 0) || + (Q_stricmp(level.mapname, "mine2") == 0) || + (Q_stricmp(level.mapname, "mine3") == 0) || + (Q_stricmp(level.mapname, "mine4") == 0) || + (Q_stricmp(level.mapname, "lab") == 0) || + (Q_stricmp(level.mapname, "boss1") == 0) || + (Q_stricmp(level.mapname, "fact3") == 0) || + (Q_stricmp(level.mapname, "biggun") == 0) || + (Q_stricmp(level.mapname, "space") == 0) || + (Q_stricmp(level.mapname, "command") == 0) || + (Q_stricmp(level.mapname, "power2") == 0) || + (Q_stricmp(level.mapname, "strike") == 0)) { // invoke one of our gross, ugly, disgusting hacks self->think = SP_FixCoopSpots; diff --git a/src/game/ctf/p_weapon.c b/src/game/ctf/p_weapon.c index 149f496e..40780a44 100644 --- a/src/game/ctf/p_weapon.c +++ b/src/game/ctf/p_weapon.c @@ -550,7 +550,7 @@ void Weapon_Generic (edict_t *ent, int FRAME_ACTIVATE_LAST, int FRAME_FIRE_LAST, fire_frames, fire); // run the weapon frame again if hasted - if (stricmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 && + if (Q_stricmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 && ent->client->weaponstate == WEAPON_FIRING) return; diff --git a/src/game/ctf/q_shared.c b/src/game/ctf/q_shared.c index a14bbcc5..86bfde33 100644 --- a/src/game/ctf/q_shared.c +++ b/src/game/ctf/q_shared.c @@ -25,10 +25,6 @@ vec3_t vec3_origin = {0,0,0}; //============================================================================ -#ifdef _WIN32 -#pragma optimize( "", off ) -#endif - void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ) { float m[3][3]; @@ -70,10 +66,10 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, memset( zrot, 0, sizeof( zrot ) ); zrot[0][0] = zrot[1][1] = zrot[2][2] = 1.0F; - zrot[0][0] = cos( DEG2RAD( degrees ) ); - zrot[0][1] = sin( DEG2RAD( degrees ) ); - zrot[1][0] = -sin( DEG2RAD( degrees ) ); - zrot[1][1] = cos( DEG2RAD( degrees ) ); + zrot[0][0] = (float)cos( DEG2RAD( degrees ) ); + zrot[0][1] = (float)sin( DEG2RAD( degrees ) ); + zrot[1][0] = (float)-sin( DEG2RAD( degrees ) ); + zrot[1][1] = (float)cos( DEG2RAD( degrees ) ); R_ConcatRotations( m, zrot, tmpmat ); R_ConcatRotations( tmpmat, im, rot ); @@ -84,12 +80,6 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, } } -#ifdef _WIN32 -#pragma optimize( "", on ) -#endif - - - void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) { float angle; @@ -97,14 +87,14 @@ void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) // static to help MS compiler fp bugs angle = angles[YAW] * (M_PI*2 / 360); - sy = sin(angle); - cy = cos(angle); + sy = (float)sin(angle); + cy = (float)cos(angle); angle = angles[PITCH] * (M_PI*2 / 360); - sp = sin(angle); - cp = cos(angle); + sp = (float)sin(angle); + cp = (float)cos(angle); angle = angles[ROLL] * (M_PI*2 / 360); - sr = sin(angle); - cr = cos(angle); + sr = (float)sin(angle); + cr = (float)cos(angle); if (forward) { @@ -164,7 +154,7 @@ void PerpendicularVector( vec3_t dst, const vec3_t src ) if ( fabs( src[i] ) < minelem ) { pos = i; - minelem = fabs( src[i] ); + minelem = (float)fabs( src[i] ); } } tempvec[0] = tempvec[1] = tempvec[2] = 0.0F; @@ -250,30 +240,11 @@ void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]) float Q_fabs (float f) { -#if 0 - if (f >= 0) - return f; - return -f; -#else int tmp = * ( int * ) &f; tmp &= 0x7FFFFFFF; return * ( float * ) &tmp; -#endif } -#if defined _M_IX86 && !defined C_ONLY -#pragma warning (disable:4035) -__declspec( naked ) long Q_ftol( float f ) -{ - static int tmp; - __asm fld dword ptr [esp+4] - __asm fistp tmp - __asm mov eax, tmp - __asm ret -} -#pragma warning (default:4035) -#endif - /* =============== LerpAngle @@ -292,12 +263,6 @@ float LerpAngle (float a2, float a1, float frac) float anglemod(float a) { -#if 0 - if (a >= 0) - a -= 360*(int)(a/360); - else - a += 360*( 1 + (int)(-a/360) ); -#endif a = (360.0/65536) * ((int)(a*(65536/360.0)) & 65535); return a; } @@ -345,13 +310,12 @@ BoxOnPlaneSide Returns 1, 2, or 1 + 2 ================== */ -#if !id386 || defined __linux__ || defined __FreeBSD__ int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p) { float dist1, dist2; int sides; -// fast axial cases + // fast axial cases if (p->type < 3) { if (p->dist <= emins[p->type]) @@ -361,44 +325,43 @@ int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p) return 3; } -// general case + // general case switch (p->signbits) { - case 0: -dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; -dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + case 0: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; break; - case 1: -dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; -dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + case 1: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; break; - case 2: -dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; -dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + case 2: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; break; - case 3: -dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; -dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + case 3: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; break; - case 4: -dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; -dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + case 4: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; break; - case 5: -dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; -dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; + case 5: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emaxs[2]; break; - case 6: -dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; -dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + case 6: + dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; break; - case 7: -dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; -dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; + case 7: + dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2]; + dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; break; - default: + default: dist1 = dist2 = 0; // shut up compiler - assert( 0 ); break; } @@ -408,250 +371,14 @@ dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2]; if (dist2 < p->dist) sides |= 2; - assert( sides != 0 ); - return sides; } -#else -#pragma warning( disable: 4035 ) - -__declspec( naked ) int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p) -{ - static int bops_initialized; - static int Ljmptab[8]; - - __asm { - - push ebx - - cmp bops_initialized, 1 - je initialized - mov bops_initialized, 1 - - mov Ljmptab[0*4], offset Lcase0 - mov Ljmptab[1*4], offset Lcase1 - mov Ljmptab[2*4], offset Lcase2 - mov Ljmptab[3*4], offset Lcase3 - mov Ljmptab[4*4], offset Lcase4 - mov Ljmptab[5*4], offset Lcase5 - mov Ljmptab[6*4], offset Lcase6 - mov Ljmptab[7*4], offset Lcase7 - -initialized: - - mov edx,ds:dword ptr[4+12+esp] - mov ecx,ds:dword ptr[4+4+esp] - xor eax,eax - mov ebx,ds:dword ptr[4+8+esp] - mov al,ds:byte ptr[17+edx] - cmp al,8 - jge Lerror - fld ds:dword ptr[0+edx] - fld st(0) - jmp dword ptr[Ljmptab+eax*4] -Lcase0: - fmul ds:dword ptr[ebx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ebx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase1: - fmul ds:dword ptr[ecx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ebx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase2: - fmul ds:dword ptr[ebx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ecx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase3: - fmul ds:dword ptr[ecx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ecx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ebx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ecx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase4: - fmul ds:dword ptr[ebx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ebx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase5: - fmul ds:dword ptr[ecx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ebx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase6: - fmul ds:dword ptr[ebx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ecx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ecx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) - jmp LSetSides -Lcase7: - fmul ds:dword ptr[ecx] - fld ds:dword ptr[0+4+edx] - fxch st(2) - fmul ds:dword ptr[ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[4+ecx] - fld ds:dword ptr[0+8+edx] - fxch st(2) - fmul ds:dword ptr[4+ebx] - fxch st(2) - fld st(0) - fmul ds:dword ptr[8+ecx] - fxch st(5) - faddp st(3),st(0) - fmul ds:dword ptr[8+ebx] - fxch st(1) - faddp st(3),st(0) - fxch st(3) - faddp st(2),st(0) -LSetSides: - faddp st(2),st(0) - fcomp ds:dword ptr[12+edx] - xor ecx,ecx - fnstsw ax - fcomp ds:dword ptr[12+edx] - and ah,1 - xor ah,1 - add cl,ah - fnstsw ax - and ah,1 - add ah,ah - add cl,ah - pop ebx - mov eax,ecx - ret -Lerror: - int 3 - } -} -#pragma warning( default: 4035 ) -#endif void ClearBounds (vec3_t mins, vec3_t maxs) -{ - mins[0] = mins[1] = mins[2] = 99999; - maxs[0] = maxs[1] = maxs[2] = -99999; -} + { + mins[0] = mins[1] = mins[2] = 99999; + maxs[0] = maxs[1] = maxs[2] = -99999; + } void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs) { @@ -683,7 +410,7 @@ vec_t VectorNormalize (vec3_t v) float length, ilength; length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); // FIXME + length = (float)sqrt (length); // FIXME if (length) { @@ -702,7 +429,7 @@ vec_t VectorNormalize2 (vec3_t v, vec3_t out) float length, ilength; length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - length = sqrt (length); // FIXME + length = (float)sqrt (length); // FIXME if (length) { @@ -718,11 +445,10 @@ vec_t VectorNormalize2 (vec3_t v, vec3_t out) void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc) { - vecc[0] = veca[0] + scale*vecb[0]; - vecc[1] = veca[1] + scale*vecb[1]; - vecc[2] = veca[2] + scale*vecb[2]; -} - + vecc[0] = veca[0] + scale*vecb[0]; + vecc[1] = veca[1] + scale*vecb[1]; + vecc[2] = veca[2] + scale*vecb[2]; +} vec_t _DotProduct (vec3_t v1, vec3_t v2) { @@ -752,10 +478,10 @@ void _VectorCopy (vec3_t in, vec3_t out) void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross) { - cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; - cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; - cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; -} + cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; + cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; + cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; +} double sqrt(double x); @@ -767,7 +493,7 @@ vec_t VectorLength(vec3_t v) length = 0; for (i=0 ; i< 3 ; i++) length += v[i]*v[i]; - length = sqrt (length); // FIXME + length = (float)sqrt (length); // FIXME return length; } @@ -786,7 +512,6 @@ void VectorScale (vec3_t in, vec_t scale, vec3_t out) out[2] = in[2]*scale; } - int Q_log2(int val) { int answer=0; @@ -885,9 +610,9 @@ COM_FilePath Returns the path up to, but not including the last / ============ */ -void COM_FilePath (char *in, char *out) +void COM_FilePath (const char *in, char *out) { - char *s; + const char *s; s = in + strlen(in) - 1; @@ -904,13 +629,13 @@ void COM_FilePath (char *in, char *out) COM_DefaultExtension ================== */ -void COM_DefaultExtension (char *path, char *extension) +void COM_DefaultExtension (char *path, const char *extension) { char *src; -// -// if path doesn't have a .EXT, append extension -// (extension should include the .) -// + // + // if path doesn't have a .EXT, append extension + // (extension should include the .) + // src = path + strlen(path) - 1; while (*src != '/' && src != path) @@ -1012,7 +737,7 @@ void Swap_Init (void) { byte swaptest[2] = {1,0}; -// set the byte swapping variables in a portable manner + // set the byte swapping variables in a portable manner if ( *(short *)swaptest == 1) { bigendien = false; @@ -1053,7 +778,7 @@ char *va(char *format, ...) static char string[1024]; va_start (argptr, format); - vsprintf (string, format,argptr); + vsnprintf (string, 1024, format, argptr); va_end (argptr); return string; @@ -1085,7 +810,7 @@ char *COM_Parse (char **data_p) return ""; } -// skip whitespace + // skip whitespace skipwhite: while ( (c = *data) <= ' ') { @@ -1097,16 +822,15 @@ skipwhite: data++; } -// skip // comments + // skip // comments if (c=='/' && data[1] == '/') { while (*data && *data != '\n') data++; goto skipwhite; } - -// handle quoted strings specially + // handle quoted strings specially if (c == '\"') { data++; @@ -1127,7 +851,7 @@ skipwhite: } } -// parse a regular word + // parse a regular word do { if (len < MAX_TOKEN_CHARS) @@ -1141,7 +865,6 @@ skipwhite: if (len == MAX_TOKEN_CHARS) { -// Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); len = 0; } com_token[len] = 0; @@ -1177,14 +900,12 @@ void Com_PageInMemory (byte *buffer, int size) ============================================================================ */ +/* PATCH: matt */ +/* use our own strncasecmp instead of this implementation */ // FIXME: replace all Q_stricmp with Q_strcasecmp -int Q_stricmp (char *s1, char *s2) +int Q_stricmp (const char *s1, const char *s2) { -#if defined(WIN32) - return _stricmp (s1, s2); -#else return strcasecmp (s1, s2); -#endif } @@ -1225,14 +946,18 @@ void Com_sprintf (char *dest, int size, char *fmt, ...) { int len; va_list argptr; - char bigbuffer[0x10000]; + static char bigbuffer[0x10000]; va_start (argptr,fmt); - len = vsprintf (bigbuffer,fmt,argptr); + len = vsnprintf (bigbuffer,0x10000,fmt,argptr); va_end (argptr); - if (len >= size) - Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size); - strncpy (dest, bigbuffer, size-1); + if (len >= size || len == size) + { + Com_Printf ("Com_sprintf: overflow\n"); + len = size-1; + } + bigbuffer[size-1] = '\0'; + strcpy (dest, bigbuffer); } /* @@ -1302,7 +1027,6 @@ void Info_RemoveKey (char *s, char *key) if (strstr (key, "\\")) { -// Com_Printf ("Can't use a key with a \\\n"); return; } @@ -1414,6 +1138,3 @@ void Info_SetValueForKey (char *s, char *key, char *value) *s = 0; } -//==================================================================== - - diff --git a/src/game/ctf/q_shared.h b/src/game/ctf/q_shared.h index 8eeffe75..4b1518f6 100644 --- a/src/game/ctf/q_shared.h +++ b/src/game/ctf/q_shared.h @@ -20,17 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // q_shared.h -- included first by ALL program modules -#ifdef _WIN32 -// unknown pragmas are SUPPOSED to be ignored, but.... -#pragma warning(disable : 4244) // MIPS -#pragma warning(disable : 4136) // X86 -#pragma warning(disable : 4051) // ALPHA - -#pragma warning(disable : 4018) // signed/unsigned mismatch -#pragma warning(disable : 4305) // truncation from const double to float - -#endif - #include #include #include @@ -39,18 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#if (defined _M_IX86 || defined __i386__) && !defined C_ONLY && !defined __sun__ -#define id386 1 -#else -#define id386 0 -#endif - -#if defined _M_ALPHA && !defined C_ONLY -#define idaxp 1 -#else -#define idaxp 0 -#endif - typedef unsigned char byte; typedef enum {false, true} qboolean; @@ -145,19 +122,15 @@ extern vec3_t vec3_origin; // microsoft's fabs seems to be ungodly slow... //float Q_fabs (float f); //#define fabs(f) Q_fabs(f) -#if !defined C_ONLY && !defined __linux__ && !defined __FreeBSD__ && !defined __sgi -extern long Q_ftol( float f ); -#else #define Q_ftol( f ) ( long ) (f) -#endif #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) -#define VectorSubtract(a,b,c) (c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2]) +#define VectorSubtract(a,b,c) (c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2]) #define VectorAdd(a,b,c) (c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2]) #define VectorCopy(a,b) (b[0]=a[0],b[1]=a[1],b[2]=a[2]) #define VectorClear(a) (a[0]=a[1]=a[2]=0) #define VectorNegate(a,b) (b[0]=-a[0],b[1]=-a[1],b[2]=-a[2]) -#define VectorSet(v, x, y, z) (v[0]=(x), v[1]=(y), v[2]=(z)) +#define VectorSet(v, x, y, z) (v[0]=(x), v[1]=(y), v[2]=(z)) void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc); @@ -212,8 +185,8 @@ void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, char *COM_SkipPath (char *pathname); void COM_StripExtension (char *in, char *out); void COM_FileBase (char *in, char *out); -void COM_FilePath (char *in, char *out); -void COM_DefaultExtension (char *path, char *extension); +void COM_FilePath (const char *in, char *out); +void COM_DefaultExtension (char *path, const char *extension); char *COM_Parse (char **data_p); // data is an in/out parm, returns a parsed out token @@ -225,7 +198,7 @@ void Com_PageInMemory (byte *buffer, int size); //============================================= // portable case insensitive compare -int Q_stricmp (char *s1, char *s2); +int Q_stricmp (const char *s1, const char *s2); int Q_strcasecmp (char *s1, char *s2); int Q_strncasecmp (char *s1, char *s2, int n); @@ -380,8 +353,6 @@ COLLISION DETECTION #define SURF_FLOWING 0x40 // scroll towards angle #define SURF_NODRAW 0x80 // don't bother referencing the texture - - // content masks #define MASK_ALL (-1) #define MASK_SOLID (CONTENTS_SOLID|CONTENTS_WINDOW) @@ -587,6 +558,24 @@ typedef struct #define EF_TRACKERTRAIL 0x80000000 //ROGUE +#ifdef QMAX +#define PART_GRAVITY 1 +#define PART_SPARK 2 +#define PART_ANGLED 4 +#define PART_DIRECTION 8 +#define PART_TRANS 16 +#define PART_SHADED 32 +#define PART_LIGHTNING 64 +#define PART_BEAM 128 +#define PART_LENSFLARE 256 +#define PART_DEPTHHACK_SHORT 512 +#define PART_DEPTHHACK_MID 1024 +#define PART_DEPTHHACK_LONG 2048 + +//combo flags +#define PART_DEPTHHACK (PART_DEPTHHACK_SHORT|PART_DEPTHHACK_MID|PART_DEPTHHACK_LONG) +#endif + // entity_state_t->renderfx flags #define RF_MINLIGHT 1 // allways have some light (viewmodel) #define RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors @@ -601,6 +590,7 @@ typedef struct #define RF_SHELL_RED 1024 #define RF_SHELL_GREEN 2048 #define RF_SHELL_BLUE 4096 +#define RF_NOSHADOW 8192 /* don't draw a shadow */ //ROGUE #define RF_IR_VISIBLE 0x00008000 // 32768 @@ -930,7 +920,7 @@ typedef enum TE_BLUEHYPERBLASTER, TE_PLASMA_EXPLOSION, TE_TUNNEL_SPARKS, -//ROGUE + //ROGUE TE_BLASTER2, TE_RAILTRAIL2, TE_FLAME, @@ -957,7 +947,7 @@ typedef enum TE_EXPLOSION1_BIG, TE_EXPLOSION1_NP, TE_FLECHETTE -//ROGUE + //ROGUE } temp_event_t; #define SPLASH_UNKNOWN 0 @@ -1040,36 +1030,6 @@ typedef enum #define DF_NO_SPHERES 0x00100000 //ROGUE -/* -ROGUE - VERSIONS -1234 08/13/1998 Activision -1235 08/14/1998 Id Software -1236 08/15/1998 Steve Tietze -1237 08/15/1998 Phil Dobranski -1238 08/15/1998 John Sheley -1239 08/17/1998 Barrett Alexander -1230 08/17/1998 Brandon Fish -1245 08/17/1998 Don MacAskill -1246 08/17/1998 David "Zoid" Kirsch -1247 08/17/1998 Manu Smith -1248 08/17/1998 Geoff Scully -1249 08/17/1998 Andy Van Fossen -1240 08/20/1998 Activision Build 2 -1256 08/20/1998 Ranger Clan -1257 08/20/1998 Ensemble Studios -1258 08/21/1998 Robert Duffy -1259 08/21/1998 Stephen Seachord -1250 08/21/1998 Stephen Heaslip -1267 08/21/1998 Samir Sandesara -1268 08/21/1998 Oliver Wyman -1269 08/21/1998 Steven Marchegiano -1260 08/21/1998 Build #2 for Nihilistic -1278 08/21/1998 Build #2 for Ensemble - -9999 08/20/1998 Internal Use -*/ -#define ROGUE_VERSION_ID 1278 - #define ROGUE_VERSION_STRING "08/21/1998 Beta 2 for Ensemble" // ROGUE @@ -1198,3 +1158,13 @@ typedef struct extern int vidref_val; // PGM // ================== + + +/* + * PATCH: eliasm + * + * Error-safe versions of fread and fwrite + */ +size_t verify_fread( void *, size_t, size_t, FILE * ); +size_t verify_fwrite( void *, size_t, size_t, FILE * ); +