summaryrefslogtreecommitdiff
path: root/src/fpsgame/server.cpp
diff options
context:
space:
mode:
authorxolatile2025-08-04 18:17:30 +0200
committerxolatile2025-08-04 18:17:30 +0200
commita89dca11cf475e0bd1399cf5d5c5135d00495ec3 (patch)
tree4d551a7f4193bc89a0b8560e955f4f874101b388 /src/fpsgame/server.cpp
parent9d533fa4d82935a083ff93a09aed95baea9fbfd4 (diff)
downloadxolatile-badassbug-a89dca11cf475e0bd1399cf5d5c5135d00495ec3.tar.xz
xolatile-badassbug-a89dca11cf475e0bd1399cf5d5c5135d00495ec3.tar.zst
Minor changes...
Diffstat (limited to 'src/fpsgame/server.cpp')
-rw-r--r--src/fpsgame/server.cpp111
1 files changed, 16 insertions, 95 deletions
diff --git a/src/fpsgame/server.cpp b/src/fpsgame/server.cpp
index e085484..08316d8 100644
--- a/src/fpsgame/server.cpp
+++ b/src/fpsgame/server.cpp
@@ -813,39 +813,6 @@ namespace server
return cname[cidx];
}
- struct servmode
- {
- virtual ~servmode() {}
-
- virtual void entergame(clientinfo *ci) {}
- virtual void leavegame(clientinfo *ci, bool disconnecting = false) {}
-
- virtual void moved(clientinfo *ci, const vec &oldpos, bool oldclip, const vec &newpos, bool newclip) {}
- virtual bool canspawn(clientinfo *ci, bool connecting = false) { return true; }
- virtual void spawned(clientinfo *ci) {}
- virtual int fragvalue(clientinfo *victim, clientinfo *actor)
- {
- if(victim==actor || isteam(victim->team, actor->team)) return -1;
- return 1;
- }
- virtual void died(clientinfo *victim, clientinfo *actor) {}
- virtual bool canchangeteam(clientinfo *ci, const char *oldteam, const char *newteam) { return true; }
- virtual void changeteam(clientinfo *ci, const char *oldteam, const char *newteam) {}
- virtual void initclient(clientinfo *ci, packetbuf &p, bool connecting) {}
- virtual void update() {}
- virtual void cleanup() {}
- virtual void setup() {}
- virtual void newmap() {}
- virtual void intermission() {}
- virtual bool hidefrags() { return false; }
- virtual int getteamscore(const char *team) { return 0; }
- virtual void getteamscores(vector<teamscore> &scores) {}
- virtual bool extinfoteam(const char *team, ucharbuf &p) { return false; }
- };
-
- #define SERVMODE 1
- servmode *smode = NULL;
-
bool canspawnitem(int type) { return !m_noitems && (type>=I_SHELLS && type<=I_QUAD && (!m_noammo || type<I_SHELLS || type>I_CARTRIDGES)); }
int spawntime(int type)
@@ -963,8 +930,7 @@ namespace server
float rank;
clientinfo *ci = choosebestclient(rank);
if(!ci) break;
- if(smode && smode->hidefrags()) rank = 1;
- else if(selected && rank<=0) break;
+ if(selected && rank<=0) break;
ci->state.timeplayed = -1;
team[first].add(ci);
if(rank>0) teamrank[first] += rank;
@@ -981,7 +947,7 @@ namespace server
{
clientinfo *ci = team[i][j];
if(!strcmp(ci->team, teamnames[i])) continue;
- if(persistteams && ci->team[0] && (!smode || smode->canchangeteam(ci, teamnames[i], ci->team)))
+ if(persistteams && ci->team[0])
{
addteaminfo(ci->team);
continue;
@@ -1024,11 +990,7 @@ namespace server
loopi(numteams-1)
{
teamrank &ts = teamranks[i];
- if(smode && smode->hidefrags())
- {
- if(ts.clients < worst->clients || (ts.clients == worst->clients && ts.rank < worst->rank)) worst = &ts;
- }
- else if(ts.rank < worst->rank || (ts.rank == worst->rank && ts.clients < worst->clients)) worst = &ts;
+ if(ts.rank < worst->rank || (ts.rank == worst->rank && ts.clients < worst->clients)) worst = &ts;
}
return worst->name;
}
@@ -1939,22 +1901,12 @@ namespace server
}
if(ci && (m_demo || m_mp(gamemode)) && ci->state.state!=CS_SPECTATOR)
{
- if(smode && !smode->canspawn(ci, true))
- {
- ci->state.state = CS_DEAD;
- putint(p, N_FORCEDEATH);
- putint(p, ci->clientnum);
- sendf(-1, 1, "ri2x", N_FORCEDEATH, ci->clientnum, ci->clientnum);
- }
- else
- {
- gamestate &gs = ci->state;
- spawnstate(ci);
- putint(p, N_SPAWNSTATE);
- putint(p, ci->clientnum);
- sendstate(gs, p);
- gs.lastspawn = gamemillis;
- }
+ gamestate &gs = ci->state;
+ spawnstate(ci);
+ putint(p, N_SPAWNSTATE);
+ putint(p, ci->clientnum);
+ sendstate(gs, p);
+ gs.lastspawn = gamemillis;
}
if(ci && ci->state.state==CS_SPECTATOR)
{
@@ -1981,7 +1933,6 @@ namespace server
putint(p, -1);
welcomeinitclient(p, ci ? ci->clientnum : -1);
}
- if(smode) smode->initclient(ci, p, true);
return 1;
}
@@ -2037,7 +1988,6 @@ namespace server
stopdemo();
pausegame(false);
changegamespeed(100);
- if(smode) smode->cleanup();
aiman::clearai();
gamemode = mode;
@@ -2060,8 +2010,6 @@ namespace server
sendf(-1, 1, "risii", N_MAPCHANGE, smapname, gamemode, 1);
- smode = NULL;
-
clearteaminfo();
if(m_teammode) autoteam();
@@ -2085,8 +2033,6 @@ namespace server
if(demonextmatch) setupdemorecord();
demonextmatch = autorecorddemo!=0;
}
-
- if(smode) smode->setup();
}
void rotatemap(bool next)
@@ -2208,18 +2154,12 @@ namespace server
if(m_teammode)
{
vector<teamscore> scores;
- if(smode && smode->hidefrags()) smode->getteamscores(scores);
loopv(clients)
{
clientinfo *ci = clients[i];
if(ci->state.state==CS_SPECTATOR || !ci->team[0]) continue;
int score = 0;
- if(smode && smode->hidefrags())
- {
- int idx = scores.htfind(ci->team);
- if(idx >= 0) score = scores[idx].score;
- }
- else if(teaminfo *ti = teaminfos.access(ci->team)) score = ti->frags;
+ if(teaminfo *ti = teaminfos.access(ci->team)) score = ti->frags;
if(!topteam || score > topscore) { topteam = ci->team; topscore = score; tied = false; }
else if(score == topscore && strcmp(ci->team, topteam)) tied = true;
}
@@ -2247,7 +2187,6 @@ namespace server
if(gamemillis >= gamelimit && !interm && (force || !checkovertime()))
{
sendf(-1, 1, "ri2", N_TIMEUP, 0);
- if(smode) smode->intermission();
changegamespeed(100);
interm = gamemillis + 10000;
}
@@ -2271,7 +2210,7 @@ namespace server
if(ts.health<=0)
{
target->state.deaths++;
- int fragvalue = smode ? smode->fragvalue(target, actor) : (target==actor || isteam(target->team, actor->team) ? -1 : 1);
+ int fragvalue = (target==actor || isteam(target->team, actor->team) ? -1 : 1);
actor->state.frags += fragvalue;
if(fragvalue>0)
{
@@ -2284,7 +2223,6 @@ namespace server
if(t) t->frags += fragvalue;
sendf(-1, 1, "ri5", N_DIED, target->clientnum, actor->clientnum, actor->state.frags, t ? t->frags : 0);
target->position.setsize(0);
- if(smode) smode->died(target, actor);
ts.state = CS_DEAD;
ts.lastdeath = gamemillis;
if(actor!=target && isteam(actor->team, target->team))
@@ -2302,14 +2240,13 @@ namespace server
{
gamestate &gs = ci->state;
if(gs.state!=CS_ALIVE) return;
- int fragvalue = smode ? smode->fragvalue(ci, ci) : -1;
+ int fragvalue = -1;
ci->state.frags += fragvalue;
ci->state.deaths++;
teaminfo *t = m_teammode ? teaminfos.access(ci->team) : NULL;
if(t) t->frags += fragvalue;
sendf(-1, 1, "ri5", N_DIED, ci->clientnum, ci->clientnum, gs.frags, t ? t->frags : 0);
ci->position.setsize(0);
- if(smode) smode->died(ci, NULL);
gs.state = CS_DEAD;
gs.lastdeath = gamemillis;
gs.respawn();
@@ -2495,7 +2432,6 @@ namespace server
}
}
aiman::checkai();
- if(smode) smode->update();
}
}
@@ -2533,7 +2469,6 @@ namespace server
void forcespectator(clientinfo *ci)
{
if(ci->state.state==CS_ALIVE) suicide(ci);
- if(smode) smode->leavegame(ci);
ci->state.state = CS_SPECTATOR;
ci->state.timeplayed += lastmillis - ci->state.lasttimeplayed;
if(!ci->local && (!ci->privilege || ci->warned)) aiman::removeai(ci);
@@ -2652,7 +2587,7 @@ namespace server
clientdisconnect(n);
}
- int clientconnect(int n, uint ip)
+ int clientconnect(int n)
{
clientinfo *ci = getinfo(n);
ci->clientnum = ci->ownernum = n;
@@ -2672,7 +2607,6 @@ namespace server
if(ci->connected)
{
if(ci->privilege) setmaster(ci, false);
- if(smode) smode->leavegame(ci, true);
ci->state.timeplayed += lastmillis - ci->state.lasttimeplayed;
savescore(ci);
sendf(-1, 1, "ri2", N_CDIS, n);
@@ -3063,7 +2997,6 @@ namespace server
cp->position.setsize(0);
while(curmsg<p.length()) cp->position.add(p.buf[curmsg++]);
}
- if(smode && cp->state.state==CS_ALIVE) smode->moved(cp, cp->state.o, cp->gameclip, pos, (flags&0x80)!=0);
cp->state.o = pos;
cp->gameclip = (flags&0x80)!=0;
}
@@ -3114,11 +3047,6 @@ namespace server
int val = getint(p);
if(!ci->local && !m_edit) break;
if(val ? ci->state.state!=CS_ALIVE && ci->state.state!=CS_DEAD : ci->state.state!=CS_EDITING) break;
- if(smode)
- {
- if(val) smode->leavegame(ci);
- else smode->entergame(ci);
- }
if(val)
{
ci->state.editstate = ci->state.state;
@@ -3159,7 +3087,7 @@ namespace server
break;
case N_TRYSPAWN:
- if(!ci || !cq || cq->state.state!=CS_DEAD || cq->state.lastspawn>=0 || (smode && !smode->canspawn(cq))) break;
+ if(!ci || !cq || cq->state.state!=CS_DEAD || cq->state.lastspawn>=0) break;
if(!ci->clientmap[0] && !ci->mapcrc)
{
ci->mapcrc = -1;
@@ -3194,7 +3122,6 @@ namespace server
cq->state.state = CS_ALIVE;
cq->state.gunselect = gunselect >= GUN_FIST && gunselect <= GUN_PISTOL ? gunselect : GUN_FIST;
cq->exceeded = 0;
- if(smode) smode->spawned(cq);
QUEUE_AI;
QUEUE_BUF({
putint(cm->messages, N_SPAWN);
@@ -3317,7 +3244,7 @@ namespace server
{
getstring(text, p);
filtertext(text, text, false, false, MAXTEAMLEN);
- if(m_teammode && text[0] && strcmp(ci->team, text) && (!smode || smode->canchangeteam(ci, ci->team, text)) && addteaminfo(text))
+ if(m_teammode && text[0] && strcmp(ci->team, text) && addteaminfo(text))
{
if(ci->state.state==CS_ALIVE) suicide(ci);
copystring(ci->team, text);
@@ -3475,7 +3402,7 @@ namespace server
if(!ci->privilege && !ci->local) break;
clientinfo *wi = getinfo(who);
if(!m_teammode || !text[0] || !wi || !wi->connected || !strcmp(wi->team, text)) break;
- if((!smode || smode->canchangeteam(wi, wi->team, text)) && addteaminfo(text))
+ if(addteaminfo(text))
{
if(wi->state.state==CS_ALIVE) suicide(wi);
copystring(wi->team, text, MAXTEAMLEN+1);
@@ -3552,7 +3479,6 @@ namespace server
smapname[0] = '\0';
resetitems();
notgotitems = false;
- if(smode) smode->newmap();
}
QUEUE_MSG;
break;
@@ -3789,11 +3715,6 @@ namespace server
sendserverinforeply(p);
}
- bool servercompatible(char *name, char *sdec, char *map, int ping, const vector<int> &attr, int np)
- {
- return attr.length() && attr[0]==PROTOCOL_VERSION;
- }
-
#include "aiman.h"
}