diff --git a/source/src/entities.cpp b/source/src/entities.cpp index f246070f..845901bc 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -6,15 +6,16 @@ vector ents; const char *entmdlnames[] = { - "pickups/pistolclips", "pickups/ammobox", "pickups/nades", "pickups/health", "pickups/helmet", "pickups/kevlar", "pickups/akimbo", + "pickups/pistolclips", "pickups/ammobox", "pickups/nade", "pickups/health", "pickups/helmet", "pickups/kevlar", "pickups/akimbo", "pickups/nades", //FIXME }; void renderent(entity &e) { - const char *mdlname = entmdlnames[e.type-I_CLIPS]; + /* FIXME: if the item list change, this "e.twice?5:0" will be messed, but it is useless to provide a general fix for now */ + const char *mdlname = entmdlnames[e.type-I_CLIPS+(e.twice&&e.type==I_GRENADE?5:0)]; float z = (float)(1+sinf(lastmillis/100.0f+e.x+e.y)/20), yaw = lastmillis/10.0f; - rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), yaw, 0); + rendermodel(mdlname, ANIM_MAPMODEL|ANIM_LOOP|ANIM_DYNALLOC, 0, 0, vec(e.x, e.y, z+S(e.x, e.y)->floor+e.attr1), yaw, 0); } void renderclip(entity &e) @@ -287,19 +288,25 @@ void spawnallitems() // spawns items locally loopv(ents) if(ents[i].fitsmode(gamemode) || (multiplayer(false) && gamespeed!=100 && (i=-1))) { ents[i].spawned = true; + ents[i].twice = false; } } void resetspawns(int type) { - loopv(ents) if(type < 0 || type == ents[i].type) ents[i].spawned = false; - if(m_noitemsnade || m_pistol) + loopv(ents) if(type < 0 || type == ents[i].type) ents[i].twice = ents[i].spawned = false; + if(m_noitemsnade || m_pistol) { - loopv(ents) ents[i].transformtype(gamemode); + loopv(ents) ents[i].transformtype(gamemode); } } -void setspawn(int i, bool on) { if(ents.inrange(i)) ents[i].spawned = on; } +void setspawn(int i, bool on) { + if(ents.inrange(i)) { + ents[i].twice = (ents[i].type == I_GRENADE && ents[i].spawned && on ? true : false); + ents[i].spawned = on; + } +} bool selectnextprimary(int num) { diff --git a/source/src/entity.h b/source/src/entity.h index e15ab3ca..d553fc97 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -31,8 +31,8 @@ struct persistent_entity // map entity struct entity : persistent_entity { - bool spawned; //the only dynamic state of a map entity - entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : persistent_entity(x, y, z, type, attr1, attr2, attr3, attr4), spawned(false) {} + bool spawned, twice; //the dynamic states of a map entity + entity(short x, short y, short z, uchar type, short attr1, uchar attr2, uchar attr3, uchar attr4) : persistent_entity(x, y, z, type, attr1, attr2, attr3, attr4), spawned(false), twice(false) {} entity() {} bool fitsmode(int gamemode) { return !m_noitems && isitem(type) && !(m_noitemsnade && type!=I_GRENADE) && !(m_pistol && type==I_AMMO); } void transformtype(int gamemode) diff --git a/source/src/server.cpp b/source/src/server.cpp index 739debb5..36cfe9e5 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1272,8 +1272,12 @@ bool serverpickup(int i, int sender) // server side item pickup, acknowl } sendf(-1, 1, "ri3", SV_ITEMACC, i, sender); cl->state.pickup(sents[i].type); + if (e.twice) { + sendf(-1, 1, "ri3", SV_ITEMACC, i, sender); + cl->state.pickup(sents[i].type); + } } - e.spawned = false; + e.spawned = e.twice = false; if(!m_lms) e.spawntime = spawntime(e.type); return true; } @@ -1289,6 +1293,10 @@ void checkitemspawns(int diff) sents[i].spawntime = 0; sents[i].spawned = true; sendf(-1, 1, "ri2", SV_ITEMSPAWN, i); + if (m_lss && sents[i].type == I_GRENADE && rnd(101) > 70 ) { + sents[i].twice = true; + sendf(-1, 1, "ri2", SV_ITEMSPAWN, i); + } } } } @@ -1678,9 +1686,10 @@ void startgame(const char *newname, int newmode, int newtime, bool notify) { e.type = smapstats.enttypes[i]; e.transformtype(smode); - server_entity se = { e.type, false, false, 0, smapstats.entposs[i * 3], smapstats.entposs[i * 3 + 1]}; + server_entity se = { e.type, false, false, false, 0, smapstats.entposs[i * 3], smapstats.entposs[i * 3 + 1]}; sents.add(se); if(e.fitsmode(smode)) sents[i].spawned = sents[i].legalpickup = true; + sents[i].twice = false; } mapbuffer.setrevision(); logline(ACLOG_INFO, "Map height density information for %s: H = %.2f V = %d, A = %d and MA = %d", smapname, Mheight, Mvolume, Marea, Mopen); diff --git a/source/src/server.h b/source/src/server.h index 726f9abb..f810fa2a 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -298,7 +298,7 @@ struct worldstate struct server_entity // server side version of "entity" type { int type; - bool spawned, legalpickup; + bool spawned, legalpickup, twice; int spawntime; short x, y; };