Guest User

Untitled

a guest
Jan 13th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.33 KB | None | 0 0
  1. comparing with https://code.google.com/r/bmartin9x-bitfighter/
  2. searching for changes
  3. diff -r 70cdfe0ad762 -r da40340a2909 zap/CoreGame.cpp
  4. --- a/zap/CoreGame.cpp  Sun Jan 13 11:57:17 2013 +0100
  5. +++ b/zap/CoreGame.cpp  Sun Jan 13 12:05:03 2013 +0100
  6. @@ -279,15 +279,33 @@
  7.     setStartingHealth(F32(CoreDefaultStartingHealth) / DamageReductionRatio);      // Hits to kill
  8.  
  9.     mHasExploded = false;
  10. -
  11.     mHeartbeatTimer.reset(CoreHeartbeatStartInterval);
  12.     mCurrentExplosionNumber = 0;
  13. -
  14.     mPanelGeom.isValid = false;
  15.  
  16.     mKillString = "crashed into a core";    // TODO: Really needed?
  17.  
  18.     LUAW_CONSTRUCTOR_INITIALIZATIONS;
  19. +  
  20. +   if(L)
  21. +   {
  22. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, TEAM_INDX, END }, { GEOM, TEAM_INDX, INT, END }}, 3 };
  23. +      S32 profile = checkArgList(L, constructorArgList, "CoreItem", "constructor");
  24. +      if(profile == 1)
  25. +      {
  26. +         setPos(getPointOrXY(L, 1));
  27. +         setTeam(getInt(L, 2));
  28. +      }
  29. +      else if(profile == 2)
  30. +      {
  31. +         setPos(getPointOrXY(L, 1));
  32. +         setTeam(getInt(L, 2));
  33. +         setStartingHealth(getInt(L, 3));
  34. +         // I've got no idea why this works and getInt(L, 2) doesn't.
  35. +         //mSpawnTime = S32(getInt(L, 3) * 1000);
  36. +         //mTimer.reset(mSpawnTime);
  37. +      }
  38. +   }
  39.  }
  40.  
  41.  
  42. diff -r 70cdfe0ad762 -r da40340a2909 zap/EngineeredItem.cpp
  43. --- a/zap/EngineeredItem.cpp    Sun Jan 13 11:57:17 2013 +0100
  44. +++ b/zap/EngineeredItem.cpp    Sun Jan 13 12:05:03 2013 +0100
  45. @@ -1689,10 +1689,20 @@
  46.  // Combined Lua / C++ default constructor
  47.  Turret::Turret(lua_State *L) : Parent(TEAM_NEUTRAL, Point(0,0), Point(1,0))
  48.  {
  49. +   // TODO: This does not work; we need to snap the turret to a nearby wall and compute the normal angle.
  50. +   // It is likely that setPos is similarly broken.  And maybe more.
  51. +   if(L)
  52. +   {
  53. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, TEAM_INDX, END }}, 2 };
  54. +      S32 profile = checkArgList(L, constructorArgList, "Turret", "constructor");
  55. +      findMountPoint(Game::getAddTarget(), getPos());
  56. +      if(profile == 1)
  57. +      {
  58. +         findMountPoint(gServerGame, getPointOrXY(L, 1));
  59. +         setTeam(getInt(L, 2));
  60. +      }
  61. +   }
  62.     initialize();
  63. -
  64. -   if(L)
  65. -      findMountPoint(Game::getAddTarget(), getPos());
  66.  }
  67.  
  68.  
  69. @@ -2039,6 +2049,8 @@
  70.  /////
  71.  // Lua interface
  72.  /**
  73. +  *  @luafunc Turret::Turret()
  74. +  *  @luafunc Turret::Turret(geom, team)
  75.    *  @luaclass Turret
  76.    *  @brief Mounted gun that shoots at enemy ships and other objects.
  77.    */
  78. diff -r 70cdfe0ad762 -r da40340a2909 zap/Spawn.cpp
  79. --- a/zap/Spawn.cpp Sun Jan 13 11:57:17 2013 +0100
  80. +++ b/zap/Spawn.cpp Sun Jan 13 12:05:03 2013 +0100
  81. @@ -206,7 +206,16 @@
  82.  // Lua constructor
  83.  Spawn::Spawn(lua_State *L) : AbstractSpawn(Point(0,0))
  84.  {
  85. +   static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }, { GEOM, TEAM_INDX, END }}, 3 };
  86. +   S32 profile = checkArgList(L, constructorArgList, "Spawn", "constructor");
  87.     initialize();
  88. +   if(L && profile == 1)
  89. +      setPos(getPointOrXY(L, 1));
  90. +   else if(L && profile == 2)
  91. +   {
  92. +      setPos(getPointOrXY(L, 1));
  93. +      setTeam(getInt(L, 2));
  94. +   }
  95.  }
  96.  
  97.  
  98. @@ -289,6 +298,9 @@
  99.  /////
  100.  // Lua interface
  101.  /**
  102. +  *  @luafunc Spawn::Spawn()
  103. +  *  @luafunc Spawn::Spawn(geom)
  104. +  *  @luafunc Spawn::Spawn(geom, team)
  105.    *  @luaclass Spawn
  106.    *  @brief Marks locations where ships and robots should spawn.
  107.    *  @geom  The geometry of Spawns is a single point.
  108. @@ -435,6 +447,22 @@
  109.  AsteroidSpawn::AsteroidSpawn(lua_State *L) : Parent(Point(0,0), DEFAULT_RESPAWN_TIME)
  110.  {
  111.     initialize();
  112. +  
  113. +   if(L)
  114. +   {
  115. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }, { GEOM, INT, END }}, 3 };
  116. +      S32 profile = checkArgList(L, constructorArgList, "AsteroidSpawn", "constructor");
  117. +      initialize();
  118. +      if(profile == 1)
  119. +         setPos(getPointOrXY(L, 1));
  120. +      else if(profile == 2)
  121. +      {
  122. +         setPos(getPointOrXY(L, 1));
  123. +         // I've got no idea why this works and getInt(L, 2) doesn't.
  124. +         mSpawnTime = S32(getInt(L, 3) * 1000);
  125. +         mTimer.reset(mSpawnTime);
  126. +      }
  127. +   }
  128.  }
  129.  
  130.  
  131. @@ -529,6 +557,9 @@
  132.  /////
  133.  // Lua interface
  134.  /**
  135. +  *  @luafunc AsteroidSpawn::AsteroidSpawn()
  136. +  *  @luafunc AsteroidSpawn::AsteroidSpawn(geom)
  137. +  *  @luafunc AsteroidSpawn::AsteroidSpawn(geom, time)
  138.    *  @luaclass AsteroidSpawn
  139.    *  @brief Spawns \link Asteroid Asteroids \endlink at regular intervals.
  140.    *  @geom  The geometry of AsteroidSpawns is a single point.
  141. @@ -562,6 +593,21 @@
  142.  CircleSpawn::CircleSpawn(lua_State *L) : Parent(Point(0,0), DEFAULT_RESPAWN_TIME)
  143.  {
  144.     initialize();
  145. +  
  146. +   if(L)
  147. +   {
  148. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }, { GEOM, INT, END }}, 3 };
  149. +      S32 profile = checkArgList(L, constructorArgList, "CircleSpawn", "constructor");
  150. +      if(profile == 1)
  151. +         setPos(getPointOrXY(L, 1));
  152. +      else if(profile == 2)
  153. +      {
  154. +         setPos(getPointOrXY(L, 1));
  155. +         // I've got no idea why this works and getInt(L, 2) doesn't.
  156. +         mSpawnTime = S32(getInt(L, 3) * 1000);
  157. +         mTimer.reset(mSpawnTime);
  158. +      }
  159. +   }
  160.  }
  161.  
  162.  
  163. @@ -658,6 +704,9 @@
  164.  /////
  165.  // Lua interface
  166.  /**
  167. +  *  @luafunc CircleSpawn::CircleSpawn()
  168. +  *  @luafunc CircleSpawn::CircleSpawn(geom)
  169. +  *  @luafunc CircleSpawn::CircleSpawn(geom, time)
  170.    *  @luaclass CircleSpawn
  171.    *  @brief Spawns \link Circle Circles \endlink at regular intervals.
  172.    *  @geom  The geometry of CircleSpawns is a single point.
  173. diff -r 70cdfe0ad762 -r da40340a2909 zap/UIGame.cpp
  174. --- a/zap/UIGame.cpp    Sun Jan 13 11:57:17 2013 +0100
  175. +++ b/zap/UIGame.cpp    Sun Jan 13 12:05:03 2013 +0100
  176. @@ -2290,7 +2290,7 @@
  177.     { "addbots",     &GameUserInterface::addBotsHandler,         { xINT, STR, TEAM, STR }, 4, LEVEL_COMMANDS,  1,  2,  {"[count]","[file]","[team name or num]","[args]"}, "Add [count] bots from [file] to [team num], pass [args] to bot" },
  178.     { "kickbot",     &GameUserInterface::kickBotHandler,         {  },                     0, LEVEL_COMMANDS,  1,  1,  {  },                                       "Kick most recently added bot" },
  179.     { "kickbots",    &GameUserInterface::kickBotsHandler,        {  },                     0, LEVEL_COMMANDS,  1,  1,  {  },                                       "Kick all bots" },
  180. -   {"announce",      &GameUserInterface::announceHandler,          { STR },                  1, ADMIN_COMMANDS,  0,  1,  {"<ANNOUNCEMENT>"},      "The admin announces an important message"   },
  181. +   {"announce",        &GameUserInterface::announceHandler,        { STR },                  1, ADMIN_COMMANDS,  0,  1,  {"<ANNOUNCEMENT>"},      "The admin announces an important message"   },
  182.  
  183.     { "kick",               &GameUserInterface::kickPlayerHandler,         { NAME },       1, ADMIN_COMMANDS,  0,  1,  {"<name>"},              "Kick a player from the game" },
  184.     { "ban",                &GameUserInterface::banPlayerHandler,          { NAME, xINT }, 2, ADMIN_COMMANDS,  0,  1,  {"<name>","[duration]"}, "Ban a player from the server (IP-based, def. = 60 mins)" },
  185. diff -r 70cdfe0ad762 -r da40340a2909 zap/Zone.cpp
  186. --- a/zap/Zone.cpp  Sun Jan 13 11:57:17 2013 +0100
  187. +++ b/zap/Zone.cpp  Sun Jan 13 12:05:03 2013 +0100
  188. @@ -26,6 +26,7 @@
  189.  #include "Zone.h"
  190.  #include "game.h"
  191.  #include "stringUtils.h"
  192. +#include "Geometry.h"
  193.  
  194.  namespace Zap
  195.  {
  196. @@ -36,6 +37,17 @@
  197.  // Combined Lua / C++ constructor)
  198.  Zone::Zone(lua_State *L)  
  199.  {
  200. +   if(L)
  201. +   {
  202. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }}, 2 };
  203. +      S32 profile = checkArgList(L, constructorArgList, "Zone", "constructor");
  204. +        
  205. +      if(profile == 1)
  206. +      {
  207. +         setGeom(L, 1);
  208. +      }
  209. +   }
  210. +  
  211.     setTeam(TEAM_NEUTRAL);
  212.     mObjectTypeNumber = ZoneTypeNumber;
  213.  
  214. @@ -148,7 +160,9 @@
  215.  /////
  216.  // Lua interface
  217.  
  218. -/**
  219. +/**
  220. +  *  @luafunc Zone::Zone()
  221. +  *  @luafunc Zone::Zone(geom)
  222.    *  @luaclass Zone
  223.    *  @brief Invisible objects, used mainly for generating events.
  224.    */
  225. diff -r 70cdfe0ad762 -r da40340a2909 zap/barrier.cpp
  226. --- a/zap/barrier.cpp   Sun Jan 13 11:57:17 2013 +0100
  227. +++ b/zap/barrier.cpp   Sun Jan 13 12:05:03 2013 +0100
  228. @@ -31,6 +31,7 @@
  229.  #include "game.h"
  230.  #include "config.h"
  231.  #include "stringUtils.h"
  232. +#include "LuaWrapper.h"
  233.  
  234.  #ifndef ZAP_DEDICATED
  235.  #  include "OpenglUtils.h"
  236. @@ -349,6 +350,18 @@
  237.     mAlreadyAdded = false;
  238.  
  239.     setNewGeometry(geomPolyLine);
  240. +  
  241. +   if(L)
  242. +   {
  243. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, INT, END }}, 2 };
  244. +      S32 profile = checkArgList(L, constructorArgList, "WallItem", "constructor");
  245. +      if(profile == 1)
  246. +      {
  247. +         setWidth(lua_tointeger(L, -1));
  248. +         lua_pop(L, 1);
  249. +         setGeom(L);
  250. +      }
  251. +   }
  252.  
  253.     LUAW_CONSTRUCTOR_INITIALIZATIONS;
  254.  }
  255. @@ -571,6 +584,8 @@
  256.  /////
  257.  // Lua interface
  258.  /**
  259. +  *  @luafunc WallItem::WallItem()
  260. +  *  @luafunc WallItem::WallItem(geom, thickness)
  261.    *  @luaclass WallItem
  262.    *  @brief Traditional wall item.
  263.    *  @descr A %WallItem is a traditional wall consisting of a series of straight-line segments.  WallItems have a width setting that
  264. diff -r 70cdfe0ad762 -r da40340a2909 zap/flagItem.cpp
  265. --- a/zap/flagItem.cpp  Sun Jan 13 11:57:17 2013 +0100
  266. +++ b/zap/flagItem.cpp  Sun Jan 13 12:05:03 2013 +0100
  267. @@ -45,6 +45,21 @@
  268.  FlagItem::FlagItem(lua_State *L) : Parent(Point(0,0), true, (F32)Ship::CollisionRadius) // radius was 20
  269.  {
  270.     initialize();
  271. +  
  272. +   if(L)
  273. +   {
  274. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }, { GEOM, TEAM_INDX, END }}, 3 };
  275. +      S32 profile = checkArgList(L, constructorArgList, "FlagItem", "constructor");
  276. +      if(profile == 1)
  277. +      {
  278. +         setPos(getPointOrXY(L, 1));
  279. +      }
  280. +      else if(profile == 2)
  281. +      {
  282. +         setPos(getPointOrXY(L, 1));
  283. +         setTeam(getInt(L, 2));
  284. +      }
  285. +   }
  286.  }
  287.  
  288.  
  289. @@ -396,6 +411,9 @@
  290.  // Lua interface
  291.  
  292.  /**
  293. +  *  @luafunc  FlagItem::FlagItem()
  294. +  *  @luafunc  FlagItem::FlagItem(geom)
  295. +  *  @luafunc  FlagItem::FlagItem(geom, team)
  296.    *  @luaclass FlagItem
  297.    *  @brief    Flags are used in many games, such as Nexus and Capture The Flag (CTF).
  298.    *  @geom     The geometry of a %FlagItem is a point.
  299. diff -r 70cdfe0ad762 -r da40340a2909 zap/moveObject.cpp
  300. --- a/zap/moveObject.cpp    Sun Jan 13 11:57:17 2013 +0100
  301. +++ b/zap/moveObject.cpp    Sun Jan 13 12:05:03 2013 +0100
  302. @@ -1310,6 +1310,16 @@
  303.     mDesign = TNL::Random::readI(0, ASTEROID_DESIGNS - 1);
  304.  
  305.     mKillString = "crashed into an asteroid";
  306. +  
  307. +   if(L)
  308. +   {
  309. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }}, 2 };
  310. +      S32 profile = checkArgList(L, constructorArgList, "Asteroid", "constructor");
  311. +      if(profile == 1)
  312. +      {
  313. +         setPos(getPointOrXY(L, 1));
  314. +      }
  315. +   }
  316.  
  317.     LUAW_CONSTRUCTOR_INITIALIZATIONS;
  318.  }
  319. @@ -1601,6 +1611,8 @@
  320.  // Lua interface
  321.  
  322.  /**
  323. + *   @luafunc Asteroid::Asteroid()
  324. + *   @luafunc Asteroid::Asteroid(geom)
  325.   *   @luaclass Asteroid
  326.   *   @brief    Just like the arcade game!  Yo!
  327.   */
  328. diff -r 70cdfe0ad762 -r da40340a2909 zap/projectile.cpp
  329. --- a/zap/projectile.cpp    Sun Jan 13 11:57:17 2013 +0100
  330. +++ b/zap/projectile.cpp    Sun Jan 13 12:05:03 2013 +0100
  331. @@ -1017,7 +1017,20 @@
  332.  // Combined Lua / C++ default constructor -- used in Lua and editor
  333.  SpyBug::SpyBug(lua_State *L) : Burst(Point(0,0), Point(0,0), NULL)
  334.  {
  335. -   initialize(Point(0,0), NULL);
  336. +   if(L)
  337. +   {
  338. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, TEAM_INDX, END }}, 2 };
  339. +      S32 profile = checkArgList(L, constructorArgList, "SpyBug", "constructor");
  340. +      
  341. +      if(profile == 0)
  342. +         initialize(Point(0,0), NULL);
  343. +      else if(profile == 1)
  344. +      {
  345. +         initialize(Point(0,0), NULL);
  346. +         setPos(getPointOrXY(L, 1));
  347. +         setTeam(getInt(L, 2));
  348. +      }
  349. +   }
  350.  }
  351.  
  352.  
  353. @@ -1240,6 +1253,14 @@
  354.  
  355.  /////
  356.  // Lua interface
  357. +/**
  358. +  *  @luafunc SpyBug::SpyBug()
  359. +  *  @luafunc SpyBug::SpyBug(geom, team)
  360. +  *  @luaclass SpyBug
  361. +  *  @brief Monitors a section of the map and will show enemy ships there.
  362. +  *  @descr Can only be used/created if the Sensor module is selected.
  363. +  *         Makes surrounding areas of the commander's map visible to player and teammates.
  364. +  */
  365.  //                Fn name                  Param profiles            Profile count                          
  366.  #define LUA_METHODS(CLASS, METHOD) \
  367.  
  368. diff -r 70cdfe0ad762 -r da40340a2909 zap/speedZone.cpp
  369. --- a/zap/speedZone.cpp Sun Jan 13 11:57:17 2013 +0100
  370. +++ b/zap/speedZone.cpp Sun Jan 13 12:05:03 2013 +0100
  371. @@ -63,6 +63,9 @@
  372.  // Combined C++/Lua constructor
  373.  SpeedZone::SpeedZone(lua_State *L)
  374.  {
  375. +   static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }, { GEOM, NUM, END }}, 3 };
  376. +   S32 profile = checkArgList(L, constructorArgList, "SpeedZone", "constructor");
  377. +  
  378.     mNetFlags.set(Ghostable);
  379.     mObjectTypeNumber = SpeedZoneTypeNumber;
  380.  
  381. @@ -72,6 +75,14 @@
  382.     mUnpackInit = 0;           // Some form of counter, to know that it is a rotating speed zone
  383.  
  384.     preparePoints();           // If this is constructed by Lua, we need to have some default geometry in place
  385. +  
  386. +   if(L && profile == 1)
  387. +      setPos(getPointOrXY(L, 1));
  388. +   else if(L && profile == 2)
  389. +   {
  390. +      setPos(getPointOrXY(L, 1));
  391. +      setSpeed(getInt(L, 2));
  392. +   }
  393.  
  394.     LUAW_CONSTRUCTOR_INITIALIZATIONS;
  395.  }
  396. @@ -530,6 +541,9 @@
  397.  //// Lua methods
  398.  
  399.  /**
  400. +  *  @luafunc SpeedZone::SpeedZone()
  401. +  *  @luafunc SpeedZone::SpeedZone(geom)
  402. +  *  @luafunc SpeedZone::SpeedZone(geom, speed)
  403.    *  @luaclass SpeedZone
  404.    *  @brief Propels ships at high speed.
  405.    *  @descr SpeedZones are game objects that propel ships around a level.  Each %SpeedZone has a direction point
  406. diff -r 70cdfe0ad762 -r da40340a2909 zap/teleporter.cpp
  407. --- a/zap/teleporter.cpp    Sun Jan 13 11:57:17 2013 +0100
  408. +++ b/zap/teleporter.cpp    Sun Jan 13 12:05:03 2013 +0100
  409. @@ -86,13 +86,11 @@
  410.  {
  411.     TNLAssert(mOwner, "We need an owner here!");
  412.     mDests.push_back(dest);
  413. -
  414.     if(mDests.size() == 1)      // Just added the first dest
  415.     {
  416.        mOwner->setVert(dest, 1);
  417.        mOwner->updateExtentInDatabase();
  418.     }
  419. -  
  420.     // If we're the server, update the clients
  421.     if(mOwner->getGame() && mOwner->getGame()->isServer())
  422.        mOwner->s2cAddDestination(dest);
  423. @@ -177,7 +175,16 @@
  424.  // Combined default C++/Lua constructor
  425.  Teleporter::Teleporter(lua_State *L)
  426.  {
  427. -   initialize(Point(0,0), Point(0,0), NULL);
  428. +   initialize(Point(0,0),Point(0,0),NULL);
  429. +   // TODO: Fix this one too -- intiailze needs to be refactored because who knows
  430. +   // how many points the teleporter is getting?  could be 1, could be 2, could be many
  431. +   if(L)
  432. +   {
  433. +      static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, END }}, 2 };
  434. +      S32 profile = checkArgList(L, constructorArgList, "Teleporter", "constructor");
  435. +      if(profile == 1)
  436. +         setPos(getPointOrXY(L, 1));
  437. +   }
  438.  }
  439.  
  440.  
  441. @@ -858,6 +865,8 @@
  442.  //// Lua methods
  443.  
  444.  /**
  445. +  *  @luafunc Teleporter::Teleporter()
  446. +  *  @luafunc Teleporter::Teleporter(geom)
  447.    *  @luaclass Teleporter
  448.    *  @brief Instantly transports ships from here to there.
  449.    *  @descr A %Teleporter represents the basic teleporter object.  Every teleporter has an intake location
  450. diff -r 70cdfe0ad762 -r da40340a2909 zap/textItem.cpp
  451. --- a/zap/textItem.cpp  Sun Jan 13 11:57:17 2013 +0100
  452. +++ b/zap/textItem.cpp  Sun Jan 13 12:05:03 2013 +0100
  453. @@ -53,6 +53,9 @@
  454.  // Combined Lua / C++ constructor
  455.  TextItem::TextItem(lua_State *L)
  456.  {
  457. +   static LuaFunctionArgList constructorArgList = { {{ END }, { GEOM, STR, END }}, 2 };
  458. +   S32 profile = checkArgList(L, constructorArgList, "Spawn", "constructor");
  459. +  
  460.     mNetFlags.set(Ghostable);
  461.     mObjectTypeNumber = TextItemTypeNumber;
  462.  
  463. @@ -60,6 +63,12 @@
  464.     mSize = 20;
  465.  
  466.     LUAW_CONSTRUCTOR_INITIALIZATIONS;
  467. +  
  468. +   if(L && profile == 1)
  469. +   {
  470. +      setPos(getPointOrXY(L, 1));
  471. +      setText(getString(L, 2));
  472. +   }
  473.  }
  474.  
  475.  
  476. @@ -426,6 +435,8 @@
  477.  //// Lua methods
  478.  
  479.  /**
  480. +  *  @luafunc TextItem::TextItem()
  481. +  *  @luafunc TextItem::TextItem(geom, text)
  482.    *  @luaclass TextItem
  483.    *  @brief Display text message in level.
  484.    *  @descr A %TextItem displays text in a level.  If the %TextItem belongs to a team, it is only visible to players on that team.
Advertisement
Add Comment
Please, Sign In to add comment