#include "g_world.qh"
-#include "_all.qh"
#include "anticheat.qh"
#include "antilag.qh"
#include "g_hook.qh"
#include "ipban.qh"
#include "mapvoting.qh"
-#include "mutators/mutators_include.qh"
+#include "mutators/all.qh"
#include "race.qh"
#include "scores.qh"
#include "teamplay.qh"
#include "weapons/weaponstats.qh"
-#include "../common/buffs.qh"
+#include "../common/buffs/all.qh"
#include "../common/constants.qh"
-#include "../common/deathtypes.qh"
-#include "../common/effects.qh"
+#include "../common/deathtypes/all.qh"
#include "../common/mapinfo.qh"
#include "../common/monsters/all.qh"
#include "../common/monsters/sv_monsters.qh"
#include "../common/vehicles/all.qh"
#include "../common/notifications.qh"
+#include "../common/physics.qh"
#include "../common/playerstats.qh"
#include "../common/stats.qh"
#include "../common/teams.qh"
+#include "../common/triggers/trigger/secret.qh"
+#include "../common/triggers/target/music.qh"
#include "../common/util.qh"
#include "../common/items/all.qh"
#include "../common/weapons/all.qh"
e = edict_num(self.cnt + 1);
if(IS_REAL_CLIENT(e))
{
- WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte(MSG_BROADCAST, TE_CSQC_PINGPLREPORT);
+ WriteHeader(MSG_BROADCAST, TE_CSQC_PINGPLREPORT);
WriteByte(MSG_BROADCAST, self.cnt);
WriteShort(MSG_BROADCAST, max(1, e.ping));
WriteByte(MSG_BROADCAST, ceil(e.ping_packetloss * 255));
}
else
{
- WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte(MSG_BROADCAST, TE_CSQC_PINGPLREPORT);
+ WriteHeader(MSG_BROADCAST, TE_CSQC_PINGPLREPORT);
WriteByte(MSG_BROADCAST, self.cnt);
WriteShort(MSG_BROADCAST, 0);
WriteByte(MSG_BROADCAST, 0);
}
void PingPLReport_Spawn()
{
- pingplreport = spawn();
- pingplreport.classname = "pingplreport";
+ pingplreport = new(pingplreport);
+ make_pure(pingplreport);
pingplreport.think = PingPLReport_Think;
pingplreport.nextthink = time;
}
}
entity randomseed;
-float RandomSeed_Send(entity to, int sf)
-{SELFPARAM();
- WriteByte(MSG_ENTITY, ENT_CLIENT_RANDOMSEED);
+bool RandomSeed_Send(entity this, entity to, int sf)
+{
+ WriteHeader(MSG_ENTITY, ENT_CLIENT_RANDOMSEED);
WriteShort(MSG_ENTITY, self.cnt);
return true;
}
}
void RandomSeed_Spawn()
{SELFPARAM();
- randomseed = spawn();
+ randomseed = new(randomseed);
+ make_pure(randomseed);
randomseed.think = RandomSeed_Think;
Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
- entity oldself;
- oldself = self;
- self = randomseed;
- self.think(); // sets random seed and nextthink
- self = oldself;
+ WITH(entity, self, randomseed, randomseed.think()); // sets random seed and nextthink
}
-void spawnfunc___init_dedicated_server(void)
-{SELFPARAM();
+spawnfunc(__init_dedicated_server)
+{
// handler for _init/_init map (only for dedicated server initialization)
world_initialized = -1; // don't complain
remove = remove_unsafely;
- entity e;
- e = spawn();
+ entity e = spawn();
e.think = GotoFirstMap;
e.nextthink = time; // this is usually 1 at this point
- e = spawn();
- e.classname = "info_player_deathmatch"; // safeguard against player joining
+ e = new(info_player_deathmatch); // safeguard against player joining
self.classname = "worldspawn"; // safeguard against various stuff ;)
// needs to be done so early because of the constants they create
static_init();
- CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
- CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
- CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
+ static_init_late();
+ static_init_precache();
MapInfo_Enumerate();
MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), MapInfo_RequiredFlags(), MapInfo_ForbiddenFlags(), 0);
void WeaponStats_Init();
void WeaponStats_Shutdown();
void Physics_AddStats();
-void spawnfunc_worldspawn (void)
-{SELFPARAM();
+spawnfunc(worldspawn)
+{
float fd, l, j, n;
string s;
// needs to be done so early because of the constants they create
static_init();
- CALL_ACCUMULATED_FUNCTION(RegisterTurrets);
- CALL_ACCUMULATED_FUNCTION(RegisterNotifications);
- CALL_ACCUMULATED_FUNCTION(RegisterDeathtypes);
-
- initialize_minigames();
ServerProgsDB = db_load(strcat("server.db", autocvar_sessionid));
PlayerStats_GameReport_Init(); // we need this to be initiated before InitGameplayMode
- precache_model ("null"); // we need this one before InitGameplayMode
InitGameplayMode();
+ static_init_late();
+ static_init_precache();
readlevelcvars();
GrappleHookInit();
MUTATOR_CALLHOOK(BuildMutatorsString, s);
s = ret_string;
- // simple, probably not good in the mutator system
- if(autocvar_g_grappling_hook)
- s = strcat(s, ":grappling_hook");
-
// initialiation stuff, not good in the mutator system
if(!autocvar_g_use_ammunition)
s = strcat(s, ":no_use_ammunition");
world_initialized = 1;
}
-void spawnfunc_light (void)
-{SELFPARAM();
+spawnfunc(light)
+{
//makestatic (self); // Who the f___ did that?
remove(self);
}
return strcat("maps/", argv(position), ".bsp");
}
-string strwords(string s, float w)
-{
- float endpos;
- for(endpos = 0; w && endpos >= 0; --w)
- endpos = strstrofs(s, " ", endpos + 1);
- if(endpos < 0)
- return s;
- else
- return substring(s, 0, endpos);
-}
-
-float strhasword(string s, string w)
-{
- return strstrofs(strcat(" ", s, " "), strcat(" ", w, " "), 0) >= 0;
-}
-
void Map_MarkAsRecent(string m)
{
cvar_set("g_maplist_mostrecent", strwords(strcat(m, " ", autocvar_g_maplist_mostrecent), max(0, autocvar_g_maplist_mostrecent_count)));
{
s = strcat(":player:see-labels:", GetPlayerScoreString(other, 0), ":");
s = strcat(s, ftos(rint(time - other.jointime)), ":");
- if(IS_PLAYER(other) || other.caplayer == 1 || g_lms)
+ if(IS_PLAYER(other) || MUTATOR_CALLHOOK(GetPlayerStatus, other, s))
s = strcat(s, ftos(other.team), ":");
else
s = strcat(s, "spectator:");
e.solid = SOLID_NOT;
e.movetype = MOVETYPE_NONE;
e.takedamage = DAMAGE_NO;
- if(e.weaponentity)
+ for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
- e.weaponentity.effects = EF_NODRAW;
- if (e.weaponentity.weaponentity)
- e.weaponentity.weaponentity.effects = EF_NODRAW;
+ .entity weaponentity = weaponentities[slot];
+ if(e.(weaponentity))
+ {
+ e.(weaponentity).effects = EF_NODRAW;
+ if (e.(weaponentity).(weaponentity))
+ e.(weaponentity).(weaponentity).effects = EF_NODRAW;
+ }
}
if(IS_REAL_CLIENT(e))
{
bprint(other.netname, " ^7wins.\n");
}
+ entity oldself = self;
+ target_music_kill();
+ self = oldself;
+
if(autocvar_g_campaign)
CampaignPreIntermission();
}
else
{
- entity oldself;
- oldself = self;
- self = ent;
- assault_new_round();
- self = oldself;
+ WITH(entity, self, ent, assault_new_round());
}
}
}
return status;
}
-// LMS winning condition: game terminates if and only if there's at most one
-// one player who's living lives. Top two scores being equal cancels the time
-// limit.
-float WinningCondition_LMS()
-{
- entity head, head2;
- float have_player;
- float have_players;
- float l;
-
- have_player = false;
- have_players = false;
- l = LMS_NewPlayerLives();
-
- head = find(world, classname, "player");
- if(head)
- have_player = true;
- head2 = find(head, classname, "player");
- if(head2)
- have_players = true;
-
- if(have_player)
- {
- // we have at least one player
- if(have_players)
- {
- // two or more active players - continue with the game
- }
- else
- {
- // exactly one player?
-
- ClearWinners();
- SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out
-
- if(l)
- {
- // game still running (that is, nobody got removed from the game by a frag yet)? then continue
- return WINNING_NO;
- }
- else
- {
- // a winner!
- // and assign him his first place
- PlayerScore_Add(head, SP_LMS_RANK, 1);
- return WINNING_YES;
- }
- }
- }
- else
- {
- // nobody is playing at all...
- if(l)
- {
- // wait for players...
- }
- else
- {
- // SNAFU (maybe a draw game?)
- ClearWinners();
- LOG_TRACE("No players, ending game.\n");
- return WINNING_YES;
- }
- }
-
- // When we get here, we have at least two players who are actually LIVING,
- // now check if the top two players have equal score.
- WinningConditionHelper();
-
- ClearWinners();
- if(WinningConditionHelper_winner)
- WinningConditionHelper_winner.winning = true;
- if(WinningConditionHelper_topscore == WinningConditionHelper_secondscore)
- return WINNING_NEVER;
-
- // Top two have different scores? Way to go for our beloved TIMELIMIT!
- return WINNING_NO;
-}
-
void ShuffleMaplist()
{
cvar_set("g_maplist", shufflewords(autocvar_g_maplist));
return;
}
- float checkrules_status;
- checkrules_status = WinningCondition_RanOutOfSpawns();
+ int checkrules_status = WinningCondition_RanOutOfSpawns();
if(checkrules_status == WINNING_YES)
- {
bprint("Hey! Someone ran out of spawns!\n");
- }
- else if(g_race && !g_race_qualifying && timelimit >= 0)
- {
- checkrules_status = WinningCondition_Race(fraglimit);
- //print("WC_RACE yields ", ftos(checkrules_status), "\n");
- }
- else if(g_race && g_race_qualifying == 2 && timelimit >= 0)
- {
- checkrules_status = WinningCondition_QualifyingThenRace(fraglimit);
- //print("WC_QUALIFYING_THEN_RACE yields ", ftos(checkrules_status), "\n");
- }
- else if(g_assault)
- {
- checkrules_status = WinningCondition_Assault(); // TODO remove this?
- }
- else if(g_lms)
- {
- checkrules_status = WinningCondition_LMS();
- }
+ else if(MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit))
+ checkrules_status = ret_float;
else
- {
checkrules_status = WinningCondition_Scores(fraglimit, leadlimit);
- //print("WC_SCORES yields ", ftos(checkrules_status), "\n");
- }
if(checkrules_status == WINNING_STARTSUDDENDEATHOVERTIME)
{
anticheat_endframe();
float altime;
- FOR_EACH_REALCLIENT(self)
+ entity e_;
+ FOR_EACH_REALCLIENT(e_)
{
- entity e = IS_SPEC(self) ? self.enemy : self;
+ entity e = IS_SPEC(e_) ? e_.enemy : e_;
if(e.typehitsound)
- self.typehit_time = time;
+ e_.typehit_time = time;
else if(e.damage_dealt)
{
- self.hit_time = time;
- self.damage_dealt_total += ceil(e.damage_dealt);
+ e_.hit_time = time;
+ e_.damage_dealt_total += ceil(e.damage_dealt);
}
}
altime = time + frametime * (1 + autocvar_g_antilag_nudge);
// add another frametime because client shows everything with
// 1 frame of lag (cl_nolerp 0). The last +1 however should not be
// needed!
- FOR_EACH_CLIENT(self)
+ FOR_EACH_CLIENT(e_)
+ {
+ e_.typehitsound = false;
+ e_.damage_dealt = 0;
+ setself(e_);
+ antilag_record(e_, altime);
+ }
+ FOR_EACH_MONSTER(e_)
{
- self.typehitsound = false;
- self.damage_dealt = 0;
- antilag_record(self, altime);
+ setself(e_);
+ antilag_record(e_, altime);
}
- FOR_EACH_MONSTER(self)
- antilag_record(self, altime);
}
redirection_nextthink = time + 1;
clients_found = 0;
- FOR_EACH_REALCLIENT(self)
+ entity e;
+ FOR_EACH_REALCLIENT(e)
{
+ setself(e);
// TODO add timer
LOG_INFO("Redirecting: sending connect command to ", self.netname, "\n");
if(redirection_target == "self")