diff --git a/source/src/bot/ac_bot.cpp b/source/src/bot/ac_bot.cpp index f16f4f93..f3886e2d 100644 --- a/source/src/bot/ac_bot.cpp +++ b/source/src/bot/ac_bot.cpp @@ -23,16 +23,15 @@ extern void spawnstate(playerent *d); void CACBot::Spawn() { - // Init all bot variabeles - spawnplayer(m_pMyEnt); - + // Init all bot variabeles m_pMyEnt->primary = m_pMyEnt->nextprimary = 2 + rnd(4); m_pMyEnt->targetyaw = m_pMyEnt->targetpitch = 0.0f; equip(this->m_pMyEnt); m_pMyEnt->armour = 0; m_pMyEnt->pBot = this; - + SelectGun(m_pMyEnt->primary); + spawnplayer(m_pMyEnt); m_eCurrentBotState = STATE_NORMAL; m_iShootDelay = m_iChangeWeaponDelay = 0; diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 48960efa..fe4ef762 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -56,7 +56,7 @@ void spawnstate(playerent *d) // reset player state not persistent setscope(false); }; equip(d); - if(m_osok) d->health = 1; + if(m_osok) d->health = 1; dblend = 0; }; @@ -674,9 +674,14 @@ void setmaster(char *claim, char *password) void mastercommand(int cmd, int a) // one of MCMD_* { - addmsg(SV_MASTERCMD, "rii", cmd, a); + if(player1->ismaster) addmsg(SV_MASTERCMD, "rii", cmd, a); + else conoutf("\f3you have to be master to perform this action"); }; +void kick(int player) { mastercommand(MCMD_KICK, player); }; +void ban(int player) { mastercommand(MCMD_BAN, player); }; +void removebans() { mastercommand(MCMD_REMBANS, 0); }; + struct mline { string cmd; }; static vector mlines; @@ -691,12 +696,14 @@ void showmastermenu(int m) // 0=kick, 1=ban loopv(players) if(players[i]) { string &s = mlines.add().cmd; - s_sprintf(s)("mastercommand %d %d", m, i); + s_sprintf(s)("%s %d", m == MCMD_KICK ? "kick" : "ban", i); menumanual(menu, item++, players[i]->name, s); }; menuset(menu); }; COMMAND(setmaster, ARG_2STR); -COMMAND(mastercommand, ARG_2INT); +COMMAND(kick, ARG_1INT); +COMMAND(ban, ARG_1INT); +COMMAND(removebans, ARG_NONE); COMMAND(showmastermenu, ARG_1INT); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index b4e0d12f..306126c1 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -427,6 +427,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) f.flag->y = (ushort) (getint(p)/DMF); f.flag->z = (ushort) (getint(p)/DMF); f.flag->z -= 4; + float floor = (float)S(f.flag->x, f.flag->y)->floor; if(f.flag->z > hdr.waterlevel) // above water { @@ -505,3 +506,22 @@ void localservertoclient(int chan, uchar *buf, int len) // processes any updat }; }; +void test1(int x, int y) +{ + conoutf("mipsize %i", mipsize); + conoutf("world : %i %i %i", sizeof(world), sizeof(world[0]), sizeof(&world) / sizeof(world[0])); + + sqr *q = S_SECURE(x, y); + if(q) + conoutf("%i\n", q->floor); + else conoutf("invalid!"); +}; + +COMMAND(test1, ARG_2INT); + +void test2() +{ + conoutf("%f %f %f", player1->o.x, player1->o.y, (float) S((ushort)(player1->o.x), (ushort)(player1->o.y))->floor); +}; + +COMMAND(test2, ARG_NONE); \ No newline at end of file diff --git a/source/src/entities.cpp b/source/src/entities.cpp index ac02a565..0ce3edc5 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -269,9 +269,23 @@ void equip(playerent *d) else if(m_lss) d->primary = GUN_KNIFE; else d->primary = d->nextprimary; + loopi(NUMGUNS) d->ammo[i] = d->mag[i] = 0; + d->mag[GUN_KNIFE] = d->ammo[GUN_KNIFE] = 1; d->mag[GUN_GRENADE] = d->ammo[GUN_GRENADE] = 0; + if(!m_nopistol) + { + d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].max-magsize(GUN_PISTOL); + d->mag[GUN_PISTOL] = magsize(GUN_PISTOL); + } + if(!m_noprimary) + { + d->ammo[d->primary] = itemstats[d->primary].start-magsize(d->primary); + d->mag[d->primary] = magsize(d->primary); + } + + /* if(m_pistol) // pistol only mode { d->ammo[GUN_PISTOL] = itemstats[GUN_PISTOL].max-magsize(GUN_PISTOL); @@ -287,7 +301,7 @@ void equip(playerent *d) d->mag[GUN_PISTOL] = magsize(GUN_PISTOL); d->ammo[d->primary] = itemstats[d->primary].start-magsize(d->primary); d->mag[d->primary] = magsize(d->primary); - }; + };*/ if (d->hasarmour) { diff --git a/source/src/entity.h b/source/src/entity.h index b8d1b39a..c9b44032 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -192,7 +192,7 @@ struct playerent : dynent }; }; -struct CBot; +class CBot; struct botent : playerent { diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 9e32caae..034d5b2c 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -215,9 +215,12 @@ bool menukey(int code, bool isdown) int n = curmenu->items.length(); if(menusel<0) menusel = n>0 ? n-1 : 0; else if(menusel>=n) menusel = 0; - curmenu->menusel = menusel; - char *haction = curmenu->items[menusel].hoveraction; - if(menusel != oldmenusel && haction) execute(haction); + if(curmenu->items.inrange(menusel)) + { + curmenu->menusel = menusel; + char *haction = curmenu->items[menusel].hoveraction; + if(menusel != oldmenusel && haction) execute(haction); + }; } else { diff --git a/source/src/server.cpp b/source/src/server.cpp index df484b7d..61a93606 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -376,14 +376,14 @@ void readscfg(char *cfg) l = buf; bool lastline = false; - while((p = strstr(l, "\n")) != NULL || (l && (lastline=true))) // remove empty/invalid lines + while((p = strstr(l, "\n")) != NULL || (l[0] && (lastline=true))) // remove empty/invalid lines { size_t len = lastline ? strlen(l) : p-l; string line; s_strncpy(line, l, len+1); char *d = line; int n = 0; - while((p = strstr(d, ":")) != NULL && (d = p+1)) n++; + while((p = strstr(d, ":")) != NULL) { d = p+1; n++; }; if(n!=3) memset(l, ' ', len+1); if(lastline) { l[len+1] = 0; break; }; l += len+1; diff --git a/source/src/world.h b/source/src/world.h index b8a5c6d3..dbbd45ce 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -49,6 +49,7 @@ struct header // map file format header #define SWS(w,x,y,s) (&(w)[(y)*(s)+(x)]) #define SW(w,x,y) SWS(w,x,y,ssize) #define S(x,y) SW(world,x,y) // convenient lookup of a lowest mip cube +#define S_SECURE(x, y) ((y)*ssize+(x) < sizeof(world) / sizeof(world[0]) ? S(x,y) : NULL) // same as above, but validates coords #define SMALLEST_FACTOR 6 // determines number of mips there can be #define DEFAULT_FACTOR 8 #define LARGEST_FACTOR 11 // 10 is already insane