From 4de620f757506e5076cd818b7363978c06ce754c Mon Sep 17 00:00:00 2001 From: sireus Date: Tue, 26 Apr 2011 13:22:35 +0000 Subject: [PATCH] entproperty now works in MP coop, but buffered git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6359 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 2 ++ source/src/entities.cpp | 15 +++++++++++++++ source/src/protos.h | 2 ++ source/src/world.cpp | 3 +++ 4 files changed, 22 insertions(+) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 41b028c1..1c6e7d87 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -568,6 +568,7 @@ void updateworld(int curtime, int lastmillis) // main game update loop } } + syncentchanges(); physicsframe(); checkweaponswitch(); checkakimbo(); @@ -1060,6 +1061,7 @@ void resetmap(bool mrproper) clearminimap(); cleardynlights(); pruneundos(); + changedents.setsize(0); particlereset(); if(mrproper) { diff --git a/source/src/entities.cpp b/source/src/entities.cpp index eeef8b09..9141f967 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -614,3 +614,18 @@ void entstats(void) COMMAND(entstats, ARG_NONE); +vector changedents; +int lastentsync = 0; + +void syncentchanges(bool force) +{ + if(lastmillis - lastentsync < 1000 && !force) return; + loopv(changedents) if(ents.inrange(changedents[i])) + { + entity &e = ents[changedents[i]]; + addmsg(SV_EDITENT, "ri9", changedents[i], e.type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4); + } + changedents.setsize(0); + lastentsync = lastmillis; +} + diff --git a/source/src/protos.h b/source/src/protos.h index c267e2b1..8c8d4dfe 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -690,6 +690,8 @@ extern void rendermapmodels(); extern void resetspawns(int type = -1); extern void setspawn(int i, bool on); extern void checkitems(playerent *d); +extern vector changedents; +extern void syncentchanges(bool force = false); // rndmap extern void perlinarea(block &b, int scale, int seed, int psize); diff --git a/source/src/world.cpp b/source/src/world.cpp index 8d64396e..5b3d6fa5 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -186,6 +186,7 @@ void entproperty(int prop, int amount) case LIGHT: calclight(); break; case SOUND: audiomgr.preloadmapsound(e); } + if(changedents.find(n) == -1) changedents.add(n); // apply ent changes later (reduces network traffic) } hashtable mapinfo, &resdata = mapinfo; @@ -219,6 +220,7 @@ void delent() { int e = closestent(); if(e<0) { conoutf("no more entities"); return; } + syncentchanges(true); int t = ents[e].type; conoutf("%s entity deleted", entnames[t]); ents[e].type = NOTUSED; @@ -261,6 +263,7 @@ entity *newentity(int index, int x, int y, int z, char *what, int v1, int v2, in e.attr1 = (int)camera1->yaw; break; } + syncentchanges(true); addmsg(SV_EDITENT, "ri9", index<0 ? ents.length() : index, type, e.x, e.y, e.z, e.attr1, e.attr2, e.attr3, e.attr4); e.spawned = true; int oldtype = type;