diff --git a/src/g_save.c b/src/g_save.c index 5bf94db..f8d63b0 100644 --- a/src/g_save.c +++ b/src/g_save.c @@ -83,7 +83,7 @@ field_t fields[] = { {"pausetime", STOFS(pausetime), F_FLOAT, FFL_SPAWNTEMP}, {"item", STOFS(item), F_LSTRING, FFL_SPAWNTEMP}, -//need for item field in edict struct, FFL_SPAWNTEMP item will be skipped on saves + // need for item field in edict struct, FFL_SPAWNTEMP item will be skipped on saves {"item", FOFS(item), F_ITEM}, {"gravity", STOFS(gravity), F_LSTRING, FFL_SPAWNTEMP}, @@ -164,7 +164,8 @@ void InitGame (void) fraglimit = gi.cvar ("fraglimit", "0", CVAR_SERVERINFO); timelimit = gi.cvar ("timelimit", "0", CVAR_SERVERINFO); password = gi.cvar ("password", "", CVAR_USERINFO); - spectator_password = gi.cvar ("spectator_password", "", 0); + spectator_password = gi.cvar ("spectator_password", "", CVAR_USERINFO); + needpass = gi.cvar ("needpass", "0", CVAR_SERVERINFO); filterban = gi.cvar ("filterban", "1", 0); g_select_empty = gi.cvar ("g_select_empty", "0", CVAR_ARCHIVE); @@ -295,6 +296,8 @@ void WriteField2 (FILE *f, field_t *field, byte *base) fwrite (*(char **)p, len, 1, f); } break; + default: + break; } } @@ -323,7 +326,11 @@ void ReadField (FILE *f, field_t *field, byte *base) *(char **)p = NULL; else { - *(char **)p = gi.TagMalloc (len, TAG_LEVEL); + /* + SBF: FIXME - 32 extra bytes alloc'd since the saved + string might not be long enough + */ + *(char **)p = gi.TagMalloc (32+len, TAG_LEVEL); fread (*(char **)p, len, 1, f); } break; @@ -438,7 +445,7 @@ A single player death will automatically restore from the last save position. ============ */ -void WriteGame (char *filename, qboolean autosave) +void WriteGame (const char *filename, qboolean autosave) { FILE *f; int i; @@ -465,7 +472,7 @@ void WriteGame (char *filename, qboolean autosave) fclose (f); } -void ReadGame (char *filename) +void ReadGame (const char *filename) { FILE *f; int i; @@ -606,7 +613,7 @@ WriteLevel ================= */ -void WriteLevel (char *filename) +void WriteLevel (const char *filename) { int i; edict_t *ent; @@ -660,7 +667,7 @@ calling ReadLevel. No clients are connected yet. ================= */ -void ReadLevel (char *filename) +void ReadLevel (const char *filename) { int entnum; FILE *f; @@ -690,15 +697,7 @@ void ReadLevel (char *filename) // check function pointer base address fread (&base, sizeof(base), 1, f); -#ifdef _WIN32 - if (base != (void *)InitGame) - { - fclose (f); - gi.error ("ReadLevel: function pointers have moved"); - } -#else gi.dprintf("Function offsets %d\n", ((byte *)base) - ((byte *)InitGame)); -#endif // load the level locals ReadLevelLocals (f); @@ -748,3 +747,4 @@ void ReadLevel (char *filename) ent->nextthink = level.time + ent->delay; } } + diff --git a/src/g_spawn.c b/src/g_spawn.c index 7823381..4c09efa 100644 --- a/src/g_spawn.c +++ b/src/g_spawn.c @@ -345,7 +345,7 @@ void ED_CallSpawn (edict_t *ent) ED_NewString ============= */ -char *ED_NewString (char *string) +char *ED_NewString (const char *string) { char *newb, *new_p; int i,l; @@ -384,7 +384,7 @@ Takes a key/value pair and sets the binary values in an edict =============== */ -void ED_ParseField (char *key, char *value, edict_t *ent) +void ED_ParseField (const char *key, const char *value, edict_t *ent) { field_t *f; byte *b; @@ -425,6 +425,8 @@ void ED_ParseField (char *key, char *value, edict_t *ent) break; case F_IGNORE: break; + default: + break; } return; } @@ -444,15 +446,15 @@ char *ED_ParseEdict (char *data, edict_t *ent) { qboolean init; char keyname[256]; - char *com_token; + const char *com_token; init = false; memset (&st, 0, sizeof(st)); -// go through all the dictionary pairs + // go through all the dictionary pairs while (1) { - // parse key + // parse key com_token = COM_Parse (&data); if (com_token[0] == '}') break; @@ -461,7 +463,7 @@ char *ED_ParseEdict (char *data, edict_t *ent) strncpy (keyname, com_token, sizeof(keyname)-1); - // parse value + // parse value com_token = COM_Parse (&data); if (!data) gi.error ("ED_ParseEntity: EOF without closing brace"); @@ -471,8 +473,8 @@ char *ED_ParseEdict (char *data, edict_t *ent) init = true; - // keynames with a leading underscore are used for utility comments, - // and are immediately discarded by quake + // keynames with a leading underscore are used for utility comments, + // and are immediately discarded by quake if (keyname[0] == '_') continue; @@ -546,11 +548,11 @@ Creates a server's entity / program execution context by parsing textual entity definitions out of an ent file. ============== */ -void SpawnEntities (char *mapname, char *entities, char *spawnpoint) +void SpawnEntities (const char *mapname, char *entities, const char *spawnpoint) { edict_t *ent; int inhibit; - char *com_token; + const char *com_token; int i; float skill_level; @@ -596,7 +598,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 @@ -633,16 +635,6 @@ void SpawnEntities (char *mapname, char *entities, char *spawnpoint) gi.dprintf ("%i entities inhibited\n", inhibit); -#ifdef DEBUG - i = 1; - ent = EDICT_NUM(i); - while (i < globals.num_edicts) { - if (ent->inuse != 0 || ent->inuse != 1) - Com_DPrintf("Invalid entity %d\n", i); - i++, ent++; - } -#endif - G_FindTeams (); PlayerTrail_Init (); @@ -651,29 +643,6 @@ void SpawnEntities (char *mapname, char *entities, char *spawnpoint) //=================================================================== -#if 0 - // cursor positioning - xl - xr - yb - yt - xv - yv - - // drawing - statpic - pic - num - string - - // control - if - ifeq - ifbit - endif - -#endif - char *single_statusbar = "yb -24 " @@ -972,9 +941,9 @@ void SP_worldspawn (edict_t *ent) gi.modelindex ("models/objects/gibs/skull/tris.md2"); gi.modelindex ("models/objects/gibs/head2/tris.md2"); -// -// Setup light animation tables. 'a' is total darkness, 'z' is doublebright. -// + // + // Setup light animation tables. 'a' is total darkness, 'z' is doublebright. + // // 0 normal gi.configstring(CS_LIGHTS+0, "m"); diff --git a/src/g_target.c b/src/g_target.c index c9924d7..fe26ecf 100644 --- a/src/g_target.c +++ b/src/g_target.c @@ -157,7 +157,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."; } @@ -290,7 +290,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; @@ -344,7 +344,7 @@ void SP_target_splash (edict_t *self) //========================================================== -/*QUAKED target_spawner (1 0 0) (-8 -8 -8) (8 8 8) 1 2 3 4 5 6 +/*QUAKED target_spawner (1 0 0) (-8 -8 -8) (8 8 8) Set target to the type of entity you want spawned. Useful for spawning monsters and gibs in the factory levels. @@ -364,7 +364,6 @@ void use_target_spawner (edict_t *self, edict_t *other, edict_t *activator) ent = G_Spawn(); ent->classname = self->target; - ent->flags = self->flags; VectorCopy (self->s.origin, ent->s.origin); VectorCopy (self->s.angles, ent->s.angles); ED_CallSpawn (ent); @@ -880,3 +879,4 @@ void SP_target_earthquake (edict_t *self) self->noise_index = gi.soundindex ("world/quake.wav"); } + diff --git a/src/g_trigger.c b/src/g_trigger.c index 820c007..0aa048a 100644 --- a/src/g_trigger.c +++ b/src/g_trigger.c @@ -367,7 +367,7 @@ trigger_push ============================================================================== */ -#if 0 + #define PUSH_ONCE 1 static int windsound; @@ -397,52 +397,10 @@ void trigger_push_touch (edict_t *self, edict_t *other, cplane_t *plane, csurfac G_FreeEdict (self); } -void SP_trigger_push (edict_t *self) -{ - InitTrigger (self); - windsound = gi.soundindex ("misc/windfly.wav"); - self->touch = trigger_push_touch; - if (!self->speed) - self->speed = 1000; - gi.linkentity (self); -} -#endif - -// RAFAEL -#define PUSH_ONCE 1 - -static int windsound; - -void trigger_push_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf) -{ - if (strcmp(other->classname, "grenade") == 0) - { - VectorScale (self->movedir, self->speed * 10, other->velocity); - } - else if (other->health > 0) - { - VectorScale (self->movedir, self->speed * 10, other->velocity); - - if (other->client) - { - // don't take falling damage immediately from this - VectorCopy (other->velocity, other->client->oldvelocity); - if (other->fly_sound_debounce_time < level.time) - { - other->fly_sound_debounce_time = level.time + 1.5; - gi.sound (other, CHAN_AUTO, windsound, 1, ATTN_NORM, 0); - } - } - } - if (self->spawnflags & PUSH_ONCE) - G_FreeEdict (self); -} - /*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE PUSH_PLUS PUSH_RAMP Pushes the player -"speed" defaults to 1000 -"wait" defaults to 10 must use PUSH_PLUS used for on +"speed" defaults to 1000 */ void trigger_push_active (edict_t *self); @@ -664,7 +622,7 @@ void trigger_monsterjump_touch (edict_t *self, edict_t *other, cplane_t *plane, if ( !(other->svflags & SVF_MONSTER)) return; -// set XY even if not on ground, so the jump will clear lips + // set XY even if not on ground, so the jump will clear lips other->velocity[0] = self->movedir[0] * self->speed; other->velocity[1] = self->movedir[1] * self->speed; diff --git a/src/g_turret.c b/src/g_turret.c index c496cb2..13deb8c 100644 --- a/src/g_turret.c +++ b/src/g_turret.c @@ -411,3 +411,4 @@ void SP_turret_driver (edict_t *self) gi.linkentity (self); } + diff --git a/src/g_utils.c b/src/g_utils.c index c484c8b..c29dfec 100644 --- a/src/g_utils.c +++ b/src/g_utils.c @@ -155,9 +155,9 @@ void G_UseTargets (edict_t *ent, edict_t *activator) { edict_t *t; -// -// check for a delay -// + // + // check for a delay + // if (ent->delay) { // create a temp object to fire at a later time @@ -175,9 +175,9 @@ void G_UseTargets (edict_t *ent, edict_t *activator) } -// -// print the message -// + // + // print the message + // if ((ent->message) && !(activator->svflags & SVF_MONSTER)) { gi.centerprintf (activator, "%s", ent->message); @@ -187,9 +187,9 @@ void G_UseTargets (edict_t *ent, edict_t *activator) gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0); } -// -// kill killtargets -// + // + // kill killtargets + // if (ent->killtarget) { t = NULL; @@ -204,9 +204,9 @@ void G_UseTargets (edict_t *ent, edict_t *activator) } } -// -// fire targets -// + // + // fire targets + // if (ent->target) { t = NULL; @@ -315,14 +315,14 @@ float vectoyaw (vec3_t vec) { float yaw; - if (/*vec[YAW] == 0 &&*/ vec[PITCH] == 0) + if (/*vec[YAW] == 0 &&*/ vec[PITCH] == 0) { yaw = 0; if (vec[YAW] > 0) yaw = 90; else if (vec[YAW] < 0) yaw = -90; - } + } else { yaw = (int) (atan2(vec[YAW], vec[PITCH]) * 180 / M_PI); @@ -436,7 +436,6 @@ void G_FreeEdict (edict_t *ed) if ((ed - g_edicts) <= (maxclients->value + BODY_QUEUE_SIZE)) { -// gi.dprintf("tried to free special edict\n"); return; } @@ -508,9 +507,6 @@ void G_TouchSolids (edict_t *ent) } } - - - /* ============================================================================== @@ -547,3 +543,4 @@ qboolean KillBox (edict_t *ent) return true; // all clear } + diff --git a/src/g_weapon.c b/src/g_weapon.c index 74cc84e..9f64dcd 100644 --- a/src/g_weapon.c +++ b/src/g_weapon.c @@ -311,11 +311,7 @@ void blaster_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t * else { gi.WriteByte (svc_temp_entity); - // RAFAEL - //if (self->s.effects & TE_BLUEHYPERBLASTER) - // gi.WriteByte (TE_BLUEHYPERBLASTER); - //else - gi.WriteByte (TE_BLASTER); + gi.WriteByte (TE_BLASTER); gi.WritePosition (self->s.origin); if (!plane) gi.WriteDir (vec3_origin); @@ -688,7 +684,7 @@ void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick vec3_t end; trace_t tr; edict_t *ignore; - int mask; + int mask; qboolean water; VectorMA (start, 8192, aimdir, end); @@ -696,29 +692,28 @@ void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick ignore = self; water = false; mask = MASK_SHOT|CONTENTS_SLIME|CONTENTS_LAVA; - while (ignore) - { - tr = gi.trace (from, NULL, NULL, end, ignore, mask); - - if (tr.contents & (CONTENTS_SLIME|CONTENTS_LAVA)) - { - mask &= ~(CONTENTS_SLIME|CONTENTS_LAVA); - water = true; - } - else - { - //ZOID--added so rail goes through SOLID_BBOX entities (gibs, etc) - if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client) || - (tr.ent->solid == SOLID_BBOX)) - ignore = tr.ent; - else - ignore = NULL; - - if ((tr.ent != self) && (tr.ent->takedamage)) - T_Damage (tr.ent, self, self, aimdir, tr.endpos, tr.plane.normal, damage, kick, 0, MOD_RAILGUN); - } - - VectorCopy (tr.endpos, from); + while (ignore) { + tr = gi.trace (from, NULL, NULL, end, ignore, mask); + + if (tr.contents & (CONTENTS_SLIME|CONTENTS_LAVA)) { + mask &= ~(CONTENTS_SLIME|CONTENTS_LAVA); + water = true; + } + else { + //ZOID--added so rail goes through SOLID_BBOX entities (gibs, etc) + if ((tr.ent->svflags & SVF_MONSTER) || (tr.ent->client) || + (tr.ent->solid == SOLID_BBOX)) + ignore = tr.ent; + else + ignore = NULL; + + if ((tr.ent != self) && (tr.ent->takedamage)) + T_Damage (tr.ent, self, self, aimdir, tr.endpos, tr.plane.normal, damage, kick, 0, MOD_RAILGUN); + else + ignore = NULL; + } + + VectorCopy (tr.endpos, from); } // send gun puff / flash @@ -727,7 +722,6 @@ void fire_rail (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick gi.WritePosition (start); gi.WritePosition (tr.endpos); gi.multicast (self->s.origin, MULTICAST_PHS); -// gi.multicast (start, MULTICAST_PHS); if (water) { gi.WriteByte (svc_temp_entity); @@ -950,7 +944,6 @@ void fire_bfg (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, f /* fire_ionripper */ - void ionripper_sparks (edict_t *self) { gi.WriteByte (svc_temp_entity); @@ -1043,8 +1036,6 @@ void fire_ionripper (edict_t *self, vec3_t start, vec3_t dir, int damage, int sp /* fire_heat */ - - void heat_think (edict_t *self) { edict_t *target = NULL; @@ -1071,23 +1062,6 @@ void heat_think (edict_t *self) if (!visible (self, target)) continue; - // if we need to reduce the tracking cone - /* - { - vec3_t vec; - float dot; - vec3_t forward; - - AngleVectors (self->s.angles, forward, NULL, NULL); - VectorSubtract (target->s.origin, self->s.origin, vec); - VectorNormalize (vec); - dot = DotProduct (vec, forward); - - if (dot > 0.6) - continue; - } - */ - if (!infront (self, target)) continue; @@ -1158,7 +1132,6 @@ void fire_heat (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, /* fire_plasma */ - void plasma_touch (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf) { vec3_t origin; @@ -1457,8 +1430,6 @@ void fire_trap (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int spee trap->movetype = MOVETYPE_BOUNCE; trap->clipmask = MASK_SHOT; trap->solid = SOLID_BBOX; -// VectorClear (trap->mins); -// VectorClear (trap->maxs); VectorSet (trap->mins, -4, -4, 0); VectorSet (trap->maxs, 4, 4, 8); trap->s.modelindex = gi.modelindex ("models/weapons/z_trap/tris.md2");