drop more stuff

This commit is contained in:
q66 2020-04-25 01:19:04 +02:00
parent a7d5eeaee9
commit b35a80c962
4 changed files with 7 additions and 115 deletions

View file

@ -54,7 +54,6 @@ namespace game
void writeclientinfo(stream *f)
{
f->printf("name %s\n", escapestring(player1->name));
}
bool allowedittoggle()
@ -70,7 +69,6 @@ namespace game
void edittoggled(bool on)
{
if(player1->state==CS_DEAD) deathstate(player1, true);
disablezoom();
player1->respawned = -2;
}
@ -211,7 +209,6 @@ namespace game
}
}
const char *chatcolorname(gameent *d) { return colorname(d); }
void toserver(char *text) { conoutf(CON_CHAT, "%s", text); }
void sendmessages()
@ -319,12 +316,6 @@ namespace game
int size = getint(p);
if(size>=0) emptymap(size, true, NULL);
else enlargemap(true);
if(d && d!=player1)
{
int newsize = 0;
while(1<<newsize < getworldsize()) newsize++;
conoutf(size>=0 ? "%s started a new map of size %d" : "%s enlarged the map to size %d", colorname(d), newsize);
}
break;
}
@ -334,10 +325,6 @@ namespace game
}
}
void receivefile(packetbuf &p)
{
}
void parsepacketclient(int chan, packetbuf &p) // processes any updates from the server
{
if(p.packet->flags&ENET_PACKET_FLAG_UNSEQUENCED) return;
@ -346,10 +333,6 @@ namespace game
case 1:
parsemessages(-1, NULL, p);
break;
case 2:
receivefile(p);
break;
}
}
}

View file

@ -2,11 +2,9 @@
namespace game
{
int maptime = 0, maprealtime = 0, maplimit = -1;
int lastspawnattempt = 0;
static int maptime = 0, maprealtime = 0;
gameent *player1 = NULL; // our client
vector<gameent *> players; // other clients
const char *getclientmap() { return clientmap; }
@ -121,52 +119,6 @@ namespace game
return true;
}
void damaged(int damage, gameent *d, gameent *actor, bool local)
{
}
void deathstate(gameent *d, bool restore)
{
d->state = CS_DEAD;
if(d==player1)
{
disablezoom();
//d->pitch = 0;
d->roll = 0;
playsound(S_DIE2);
}
else
{
d->move = d->strafe = 0;
d->resetinterp();
d->smoothmillis = 0;
playsound(S_DIE1, &d->o);
}
}
VARP(teamcolorfrags, 0, 1, 1);
void killed(gameent *d, gameent *actor)
{
if(d->state==CS_EDITING)
{
d->editstate = CS_DEAD;
if(d!=player1) d->resetinterp();
return;
}
else if(d->state!=CS_ALIVE && d->state != CS_LAGGED && d->state != CS_SPAWNING) return;
deathstate(d);
}
void timeupdate(int secs)
{
if(secs > 0)
{
maplimit = lastmillis + secs*1000;
}
}
vector<gameent *> clients;
gameent *getclient(int cn) // ensure valid entity
@ -181,11 +133,9 @@ namespace game
gameent *d = clients[cn];
if(d)
{
if(notify && d->name[0]) conoutf("\f4leave:\f7 %s", colorname(d));
removetrackedparticles(d);
removetrackeddynlights(d);
if(cmode) cmode->removeplayer(d);
players.removeobj(d);
DELETEP(clients[cn]);
cleardynentcache();
}
@ -200,7 +150,6 @@ namespace game
{
player1 = spawnstate(new gameent);
filtertext(player1->name, "unnamed", false, false, MAXNAMELEN);
players.add(player1);
}
VARP(showmodeinfo, 0, 1, 1);
@ -208,12 +157,11 @@ namespace game
void startgame()
{
// reset perma-state
loopv(players) players[i]->startgame();
player1->startgame();
setclientmode();
maptime = maprealtime = 0;
maplimit = -1;
if(cmode)
{
@ -264,28 +212,14 @@ namespace game
playsound(n);
}
int numdynents() { return players.length(); }
int numdynents() { return 1; }
dynent *iterdynents(int i)
{
if(i<players.length()) return players[i];
if(!i) return player1;
return NULL;
}
bool duplicatename(gameent *d, const char *name = NULL, const char *alt = NULL)
{
if(!name) name = d->name;
if(alt && d != player1 && !strcmp(name, alt)) return true;
loopv(players) if(d!=players[i] && !strcmp(name, players[i]->name)) return true;
return false;
}
const char *colorname(gameent *d, const char *name, const char * alt, const char *color)
{
if(!name) name = alt && d == player1 ? alt : d->name;
return name;
}
bool needminimap() { return false; }
void drawicon(int icon, float x, float y, float sz)

View file

@ -248,24 +248,19 @@ namespace game
// game
extern string clientmap;
extern int maptime, maprealtime, maplimit;
extern gameent *player1;
extern vector<gameent *> players, clients;
extern int lastspawnattempt;
extern int smoothmove, smoothdist;
extern vector<gameent *> clients;
extern bool clientoption(const char *arg);
extern gameent *getclient(int cn);
extern gameent *newclient(int cn);
extern const char *colorname(gameent *d, const char *name = NULL, const char *alt = NULL, const char *color = "");
extern gameent *pointatplayer();
extern gameent *hudplayer();
extern void clientdisconnected(int cn, bool notify = true);
extern void clearclients(bool notify = true);
extern void startgame();
extern void spawnplayer(gameent *);
extern void deathstate(gameent *d, bool restore = false);
extern void timeupdate(int timeremain);
extern void msgsound(int n, physent *d = NULL);
// client

View file

@ -24,17 +24,12 @@ namespace server
vec o;
int state, editstate;
int lastspawn, lifesequence;
int lasttimeplayed, timeplayed;
float effectiveness;
servstate() : state(CS_DEAD), editstate(CS_DEAD), lifesequence(0) {}
void reset()
{
if(state!=CS_SPECTATOR) state = editstate = CS_DEAD;
timeplayed = 0;
effectiveness = 0;
state = editstate = CS_DEAD;
respawn();
}
@ -296,13 +291,6 @@ namespace server
putint(p, gs.lifesequence);
}
void spawnstate(clientinfo *ci)
{
servstate &gs = ci->state;
gs.spawnstate(0);
gs.lifesequence = (gs.lifesequence + 1)&0x7F;
}
void sendwelcome(clientinfo *ci)
{
packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE);
@ -327,11 +315,6 @@ namespace server
{
gamemillis = 0;
copystring(smapname, s);
loopv(clients)
{
clientinfo *ci = clients[i];
ci->state.timeplayed += lastmillis - ci->state.lasttimeplayed;
}
kicknonlocalclients(DISC_LOCAL);
@ -341,7 +324,6 @@ namespace server
{
clientinfo *ci = clients[i];
ci->mapchange();
ci->state.lasttimeplayed = lastmillis;
}
}
@ -413,7 +395,6 @@ namespace server
clientinfo *ci = getinfo(n);
if(ci->connected)
{
ci->state.timeplayed += lastmillis - ci->state.lasttimeplayed;
sendf(-1, 1, "ri2", N_CDIS, n);
clients.removeobj(ci);
if(!numclients(-1, false, true)) noclients(); // bans clear when server empties
@ -441,7 +422,6 @@ namespace server
clients.add(ci);
ci->connected = true;
ci->state.lasttimeplayed = lastmillis;
sendwelcome(ci);
}