Skip to content
Browse files

allow player models to be set at runtime

  • Loading branch information...
1 parent 3c25e97 commit 436635717944fa7bf56b8a9a325e07a1373a9274 @kripken committed Jun 11, 2012
Showing with 38 additions and 19 deletions.
  1. +7 −0 cube2/src/engine/main.cpp
  2. +26 −18 cube2/src/fpsgame/render.cpp
  3. +4 −0 cube2/src/shared/igame.h
  4. +1 −1 cube2/src/web/Makefile
View
7 cube2/src/engine/main.cpp
@@ -1203,6 +1203,13 @@ void main2()
if(initscript) execute(initscript);
+#if 0 //EMSCRIPTEN
+ emscripten_run_script("setPlayerModels()");
+#else
+ game::setplayermodelinfo("snoutx10k", "snoutx10k", "snoutx10k", "snoutx10k/hudguns", NULL, NULL, NULL, NULL, NULL, "snoutx10k", "snoutx10k", "snoutx10k", true);
+ game::setplayermodelinfo("frankie", "frankie", "frankie", NULL, "nada", NULL, NULL, NULL, NULL, "frankie", "frankie", "frankie", false);
+#endif
+
logoutf("init: mainloop");
initmumble();
View
44 cube2/src/fpsgame/render.cpp
@@ -45,32 +45,40 @@ namespace game
}
}
- static const playermodelinfo playermodels[1] =
+ // XXX EMSCRIPTEN: load different player models at runtime
+ static const int MAX_PLAYER_MODELS = 10;
+ static playermodelinfo playermodels[10];
+ static int numplayermodels = 0;
+
+ void setplayermodelinfo(const char *ffa, const char *blueteam, const char *redteam, const char *hudguns,
+ const char *vwep, const char *quad, const char *armour0, const char *armour1, const char *armour2,
+ const char *ffaicon, const char *blueicon, const char *redicon, bool ragdoll) // XXX EMSCRIPTEN: load different player models at runtime
{
-/*
- { "frankie", "frankie", "frankie", "snoutx10k/hudguns", NULL, "snoutx10k/wings", { "snoutx10k/armor/blue", "snoutx10k/armor/green", "snoutx10k/armor/yellow" }, "frankie", "frankie", "frankie", true },
- };
-*/
-// XXX EMSCRIPTEN
- { "snoutx10k", "snoutx10k/blue", "snoutx10k/red", "snoutx10k/hudguns", NULL, "snoutx10k/wings", { "snoutx10k/armor/blue", "snoutx10k/armor/green", "snoutx10k/armor/yellow" }, "snoutx10k", "snoutx10k_blue", "snoutx10k_red", true },
- };
-/*
- { "mrfixit", "mrfixit/blue", "mrfixit/red", "mrfixit/hudguns", NULL, "mrfixit/horns", { "mrfixit/armor/blue", "mrfixit/armor/green", "mrfixit/armor/yellow" }, "mrfixit", "mrfixit_blue", "mrfixit_red", true },
- //{ "ogro/green", "ogro/blue", "ogro/red", "mrfixit/hudguns", "ogro/vwep", NULL, { NULL, NULL, NULL }, "ogro", "ogro_blue", "ogro_red", false },
- { "ogro2", "ogro2/blue", "ogro2/red", "mrfixit/hudguns", NULL, NULL, { NULL, NULL, NULL }, "ogro", "ogro_blue", "ogro_red", true },
- { "inky", "inky/blue", "inky/red", "inky/hudguns", NULL, "inky/quad", { "inky/armor/blue", "inky/armor/green", "inky/armor/yellow" }, "inky", "inky_blue", "inky_red", true },
- { "captaincannon", "captaincannon/blue", "captaincannon/red", "captaincannon/hudguns", NULL, "captaincannon/quad", { "captaincannon/armor/blue", "captaincannon/armor/green", "captaincannon/armor/yellow" }, "captaincannon", "captaincannon_blue", "captaincannon_red", true }
- };
-*/
+ assert(numplayermodels < MAX_PLAYER_MODELS);
+ playermodelinfo &p = playermodels[numplayermodels++];
+ p.ffa = ffa ? newstring(ffa) : NULL;
+ p.blueteam = blueteam ? newstring(blueteam) : NULL;
+ p.redteam = redteam ? newstring(redteam) : NULL;
+ p.hudguns = hudguns ? newstring(hudguns) : NULL;
+ p.vwep = vwep ? newstring(vwep) : NULL;
+ p.quad = quad ? newstring(quad) : NULL;
+ p.armour[0] = armour0 ? newstring(armour0) : NULL;
+ p.armour[1] = armour1 ? newstring(armour1) : NULL;
+ p.armour[2] = armour2 ? newstring(armour2) : NULL;
+ p.ffaicon = ffaicon ? newstring(ffaicon) : NULL;
+ p.blueicon = blueicon ? newstring(blueicon) : NULL;
+ p.redicon = redicon ? newstring(redicon) : NULL;
+ p.ragdoll = ragdoll;
+ }
int chooserandomplayermodel(int seed)
{
- return (seed&0xFFFF)%(sizeof(playermodels)/sizeof(playermodels[0]));
+ return (seed&0xFFFF)%(numplayermodels);
}
const playermodelinfo *getplayermodelinfo(int n)
{
- if(size_t(n) >= sizeof(playermodels)/sizeof(playermodels[0])) return NULL;
+ if(size_t(n) >= numplayermodels) return NULL;
return &playermodels[n];
}
View
4 cube2/src/shared/igame.h
@@ -87,6 +87,10 @@ namespace game
extern void serverinfoendcolumn(g3d_gui *g, int i);
extern bool serverinfoentry(g3d_gui *g, int i, const char *name, int port, const char *desc, const char *map, int ping, const vector<int> &attr, int np);
extern bool needminimap();
+
+ extern void setplayermodelinfo(const char *ffa, const char *blueteam, const char *redteam, const char *hudguns,
+ const char *vwep, const char *quad, const char *armour0, const char *armour1, const char *armour2,
+ const char *ffaicon, const char *blueicon, const char *redicon, bool ragdoll); // XXX EMSCRIPTEN: load different player models at runtime
}
namespace server
View
2 cube2/src/web/Makefile
@@ -195,7 +195,7 @@ client: client.bc
packages/models/projectiles/ \
packages/caustics/ \
--pre-run > preload.js
- cd .. ; cd .. ; $(CXX) $(CXXFLAGS) src/web/client.bc src/web/libz.a -o bb.js -s TOTAL_MEMORY=31457280 -s DISABLE_EXCEPTION_CATCHING=1 --pre-js src/web/pre.js #-O2 --closure 0 #-s GL_DEBUG=1 -s LIBRARY_DEBUG=1
+ cd .. ; cd .. ; $(CXX) $(CXXFLAGS) src/web/client.bc src/web/libz.a -o bb.js -s TOTAL_MEMORY=31457280 -s DISABLE_EXCEPTION_CATCHING=1 --pre-js src/web/pre.js #-O2 #--closure 0 #-s GL_DEBUG=1 -s LIBRARY_DEBUG=1
server: libenet $(SERVER_OBJS)
$(CXX) $(CXXFLAGS) -o sauer_server $(SERVER_OBJS) $(SERVER_LIBS)

0 comments on commit 4366357

Please sign in to comment.
Something went wrong with that request. Please try again.