Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: entities.cpp
- ===================================================================
- --- entities.cpp (revision 6591)
- +++ entities.cpp (working copy)
- @@ -315,10 +315,10 @@
- switch(e.type)
- {
- default:
- - if( d->canpickup(e.type) && lastmillis > e.lastmillis + 250 && lastmillis > lastspawn + 500 )
- + if( d->canpickup(e.type) && lastmillis > e.lastmillis + 250 && lastmillis > lastspawn + 500
- + && !multiplayer(false) && serverpickup(n, -1))
- {
- - if(d->type==ENT_PLAYER) addmsg(SV_ITEMPICKUP, "ri", n);
- - else if(d->type==ENT_BOT && serverpickup(n, -1)) pickupeffects(n, d);
- + pickupeffects(n, d);
- e.lastmillis = lastmillis;
- }
- break;
- @@ -384,7 +384,7 @@
- if(dist1<1.5f && dist2<e.attr1) trypickup(i, d);
- continue;
- }
- -
- + if(multiplayer(false)) continue;
- if(!e.spawned) continue;
- if(OUTBORD(e.x, e.y)) continue;
- Index: protocol.cpp
- ===================================================================
- --- protocol.cpp (revision 6591)
- +++ protocol.cpp (working copy)
- @@ -325,7 +325,7 @@
- SV_GIBDIED, 5, SV_DIED, 5, SV_GIBDAMAGE, 7, SV_DAMAGE, 7, SV_HITPUSH, 6, SV_SHOTFX, 6, SV_THROWNADE, 8,
- SV_TRYSPAWN, 1, SV_SPAWNSTATE, 23, SV_SPAWN, 3, SV_SPAWNDENY, 2, SV_FORCEDEATH, 2, SV_RESUME, 0,
- SV_DISCSCORES, 0, SV_TIMEUP, 3, SV_EDITENT, 10, SV_ITEMACC, 2,
- - SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2, SV_ITEMPICKUP, 2,
- + SV_MAPCHANGE, 0, SV_ITEMSPAWN, 2,
- SV_PING, 2, SV_PONG, 2, SV_CLIENTPING, 2, SV_GAMEMODE, 2,
- SV_EDITMODE, 2, SV_EDITH, 7, SV_EDITT, 7, SV_EDITS, 6, SV_EDITD, 6, SV_EDITE, 6, SV_NEWMAP, 2,
- SV_SENDMAP, 0, SV_RECVMAP, 1, SV_REMOVEMAP, 0,
- Index: protocol.h
- ===================================================================
- --- protocol.h (revision 6591)
- +++ protocol.h (working copy)
- @@ -24,7 +24,7 @@
- SV_GIBDIED, SV_DIED, SV_GIBDAMAGE, SV_DAMAGE, SV_HITPUSH, SV_SHOTFX, SV_THROWNADE,
- SV_TRYSPAWN, SV_SPAWNSTATE, SV_SPAWN, SV_SPAWNDENY, SV_FORCEDEATH, SV_RESUME,
- SV_DISCSCORES, SV_TIMEUP, SV_EDITENT, SV_ITEMACC,
- - SV_MAPCHANGE, SV_ITEMSPAWN, SV_ITEMPICKUP,
- + SV_MAPCHANGE, SV_ITEMSPAWN,
- SV_PING, SV_PONG, SV_CLIENTPING, SV_GAMEMODE,
- SV_EDITMODE, SV_EDITH, SV_EDITT, SV_EDITS, SV_EDITD, SV_EDITE, SV_NEWMAP,
- SV_SENDMAP, SV_RECVMAP, SV_REMOVEMAP,
- Index: server.cpp
- ===================================================================
- --- server.cpp (revision 6591)
- +++ server.cpp (working copy)
- @@ -1379,37 +1379,13 @@
- return sec*1000;
- }
- -bool serverpickup(int i, int sender) // server side item pickup, acknowledge first client that gets it
- +bool serverpickup(int i, int sender)
- {
- - const char *hn = sender >= 0 && clients[sender]->type == ST_TCPIP ? clients[sender]->hostname : NULL;
- - if(!sents.inrange(i))
- - {
- - if(hn) logline(ACLOG_INFO, "[%s] tried to pick up entity #%d - doesn't exist on this map", hn, i);
- - return false;
- - }
- server_entity &e = sents[i];
- - if(!e.spawned)
- - {
- - if(!e.legalpickup && hn && !m_demo) logline(ACLOG_INFO, "[%s] tried to pick up entity #%d (%s) - can't be picked up in this gamemode or at all", hn, i, entnames[e.type]);
- - return false;
- - }
- if(sender>=0)
- {
- client *cl = clients[sender];
- - if(cl->type==ST_TCPIP)
- - {
- - if( cl->state.state!=CS_ALIVE || !cl->state.canpickup(e.type) || ( m_arena && !free_items(sender) ) ) return false;
- - vec v(e.x, e.y, cl->state.o.z);
- - float dist = cl->state.o.dist(v);
- - int pdist = check_pdist(cl,dist);
- - if (pdist)
- - {
- - cl->farpickups++;
- - if (!m_demo) logline(ACLOG_INFO, "[%s] %s %s up entity #%d (%s), distance %.2f (%d)",
- - cl->hostname, cl->name, (pdist==2?"tried to pick":"picked"), i, entnames[e.type], dist, cl->farpickups);
- - if (pdist==2) return false;
- - }
- - }
- + if(!e.spawned || !cl->state.canpickup(e.type) || ( m_arena && !free_items(sender) ) ) return false;
- sendf(-1, 1, "ri3", SV_ITEMACC, i, sender);
- cl->state.pickup(sents[i].type);
- if (m_lss && sents[i].type == I_GRENADE) cl->state.pickup(sents[i].type); // get two nades at lss
- @@ -1946,7 +1922,7 @@
- {
- e.type = smapstats.enttypes[i];
- e.transformtype(smode);
- - server_entity se = { e.type, false, 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], smapstats.entposs[i * 3 + 2] };
- sents.add(se);
- if(e.fitsmode(smode)) sents[i].spawned = sents[i].legalpickup = true;
- }
- @@ -2879,18 +2855,6 @@
- break;
- }
- - case SV_ITEMPICKUP:
- - {
- - int n = getint(p);
- - if(!arenaround || arenaround - gamemillis > 2000)
- - {
- - gameevent &pickup = cl->addevent();
- - pickup.type = GE_PICKUP;
- - pickup.pickup.ent = n;
- - }
- - break;
- - }
- -
- case SV_WEAPCHANGE:
- {
- int gunselect = getint(p);
- @@ -3732,6 +3696,7 @@
- if(minremain>0)
- {
- + checkitempickups();
- processevents();
- checkitemspawns(diff);
- bool ktfflagingame = false;
- Index: server.h
- ===================================================================
- --- server.h (revision 6591)
- +++ server.h (working copy)
- @@ -379,7 +379,7 @@
- int type;
- bool spawned, legalpickup, twice;
- int spawntime;
- - short x, y;
- + short x, y, elevation;
- };
- struct demofile
- @@ -422,7 +422,7 @@
- "SV_GIBDIED", "SV_DIED", "SV_GIBDAMAGE", "SV_DAMAGE", "SV_HITPUSH", "SV_SHOTFX", "SV_THROWNADE",
- "SV_TRYSPAWN", "SV_SPAWNSTATE", "SV_SPAWN", "SV_SPAWNDENY", "SV_FORCEDEATH", "SV_RESUME",
- "SV_DISCSCORES", "SV_TIMEUP", "SV_EDITENT", "SV_ITEMACC",
- - "SV_MAPCHANGE", "SV_ITEMSPAWN", "SV_ITEMPICKUP",
- + "SV_MAPCHANGE", "SV_ITEMSPAWN",
- "SV_PING", "SV_PONG", "SV_CLIENTPING", "SV_GAMEMODE",
- "SV_EDITMODE", "SV_EDITH", "SV_EDITT", "SV_EDITS", "SV_EDITD", "SV_EDITE", "SV_NEWMAP",
- "SV_SENDMAP", "SV_RECVMAP", "SV_REMOVEMAP",
- Index: serverchecks.h
- ===================================================================
- --- serverchecks.h (revision 6591)
- +++ serverchecks.h (working copy)
- @@ -21,6 +21,26 @@
- }
- }
- +void checkitempickups()
- +{
- + if(!isdedicated || m_noitems) return;
- + loopv(clients) if(clients[i] && clients[i]->type != ST_EMPTY && clients[i]->state.isalive(gamemillis))
- + {
- + client *cl = clients[i];
- + loopv(sents) if(sents[i].spawned)
- + {
- + server_entity *si = &sents[i];
- + vec pos(si->x, si->y, (float)SS(si->x, si->y)->floor + (float)si->elevation);
- + if(cl->state.o.dist(pos) < 2.5f)
- + {
- + gameevent &pickup = cl->addevent();
- + pickup.type = GE_PICKUP;
- + pickup.pickup.ent = i;
- + }
- + }
- + }
- +}
- +
- #define POW2XY(A,B) (pow2(A.x-B.x)+pow2(A.y-B.y))
- #ifdef ACAC
- Index: tools.cpp
- ===================================================================
- --- tools.cpp (revision 6591)
- +++ tools.cpp (working copy)
- @@ -71,7 +71,7 @@
- if(e.type == CTF_FLAG && (e.attr2 == 0 || e.attr2 == 1)) { s.flags[e.attr2]++; s.flagents[e.attr2] = i; }
- s.entcnt[e.type]++;
- enttypes[i] = e.type;
- - entposs[i * 3] = e.x; entposs[i * 3 + 1] = e.y; entposs[i * 3 + 2] = e.z + e.attr1;
- + entposs[i * 3] = e.x; entposs[i * 3 + 1] = e.y; entposs[i * 3 + 2] = e.attr1/* + e.z*/;
- }
- DELETEA(testlayout);
- int minfloor = 0;
- @@ -83,13 +83,15 @@
- bool fail = false;
- testlayout = new char[layoutsize + 256];
- memset(testlayout, 0, layoutsize * sizeof(char));
- - char *t = NULL;
- + ssqr *t = NULL;
- char floor = 0, ceil;
- int diff = 0;
- Mvolume = Marea = SHhits = 0;
- + s.initworld();
- loopk(layoutsize)
- {
- char *c = testlayout + k;
- + ssqr *ss = &s.serverworld[k];
- int type = f->getchar();
- int n = 1;
- switch(type)
- @@ -97,20 +99,23 @@
- case 255:
- {
- if(!t || (n = f->getchar()) < 0) { fail = true; break; }
- - memset(c, *t, n);
- - k += n - 1;
- + char tmp = *(c-1);
- + memset(c, tmp, n);
- + for(int i = 0; i<n; i++, k++) memcpy(&s.serverworld[k], t, sizeof(ssqr));
- + k--;
- break;
- }
- case 254: // only in MAPVERSION<=2
- if(!t) { fail = true; break; }
- - *c = *t;
- + *c = *(c-1);
- f->getchar(); f->getchar();
- break;
- default:
- if(type<0 || type>=MAXTYPE) { fail = true; break; }
- - floor = f->getchar();
- - ceil = f->getchar();
- - if(floor >= ceil && ceil > -128) floor = ceil - 1; // for pre 12_13
- + ss->type = type;
- + ss->floor = floor = f->getchar();
- + ss->ceil = ceil = f->getchar();
- + if(floor >= ceil && ceil > -128) ss->floor = floor = ceil - 1; // for pre 12_13
- diff = ceil - floor;
- if(type == FHF) floor = -128;
- if(floor!=-128 && floor<minfloor) minfloor = floor;
- @@ -118,8 +123,10 @@
- f->getchar(); f->getchar();
- if(s.hdr.version>=2) f->getchar();
- if(s.hdr.version>=5) f->getchar();
- -
- + *c = ss->floor;
- case SOLID:
- + *c = 127;
- + ss->type = SOLID;
- *c = type == SOLID ? 127 : floor;
- f->getchar(); f->getchar();
- if(s.hdr.version<=2) { f->getchar(); f->getchar(); }
- @@ -132,7 +139,7 @@
- Mvolume += diff * n;
- }
- if(fail) break;
- - t = c;
- + t = ss;
- }
- if(fail) { DELETEA(testlayout); }
- else
- Index: world.h
- ===================================================================
- --- world.h (revision 6591)
- +++ world.h (working copy)
- @@ -23,6 +23,13 @@
- uchar reserved[2];
- };
- +// simplified square
- +struct ssqr
- +{
- + uchar type;
- + char floor, ceil;
- +};
- +
- enum // hardcoded texture numbers
- {
- DEFAULT_SKY = 0,
- @@ -63,7 +70,30 @@
- int flagents[2];
- bool hasffaspawns;
- bool hasteamspawns;
- - bool hasflags;
- + bool hasflags;
- + ssqr *serverworld;
- +
- + void initworld()
- + {
- + DELETEA(serverworld);
- + int size = 1 << (hdr.sfactor*2);
- + serverworld = new ssqr[size];
- + memset(serverworld, 0, size*sizeof(ssqr));
- + loopi(size)
- + {
- + ssqr *ss = &serverworld[i];
- + if(!ss) continue;
- + ss->floor = 0;
- + ss->ceil = 16;
- + ss->type = SOLID;
- + }
- + }
- +
- + ~mapstats()
- + {
- + DELETEA(serverworld);
- + }
- +
- };
- #define TRANSFORMOLDENTITIES(headr) \
- @@ -117,6 +147,10 @@
- #define SWS(w,x,y,s) (&(w)[((y)<<(s))+(x)])
- #define SW(w,x,y) SWS(w,x,y,sfactor)
- #define S(x,y) SW(world,x,y) // convenient lookup of a lowest mip cube
- +
- +#define SSW(w,x,y) SWS(w,x,y,smapstats.hdr.sfactor)
- +#define SS(x,y) SSW(smapstats.serverworld,x,y)
- +
- #define SMALLEST_FACTOR 6 // determines number of mips there can be
- #define DEFAULT_FACTOR 8
- #define LARGEST_FACTOR 11 // 10 is already insane
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement