Permalink
Browse files

Merge branch 'bugfixes' into 3.1

  • Loading branch information...
2 parents cf77b27 + 9775d0c commit 4879779b631235bdfa5890a0cbfcdeea79023656 automerge committed with cybersphinx Apr 25, 2012
@@ -1061,7 +1061,6 @@ int NETinit(bool bFirstCall)
return 0;
}
-
// ////////////////////////////////////////////////////////////////////////
// SHUTDOWN THE CONNECTION.
int NETshutdown(void)
@@ -1072,7 +1071,12 @@ int NETshutdown(void)
if (IPlist)
free(IPlist);
IPlist = NULL;
-
+ if (NetPlay.MOTD)
+ {
+ free(NetPlay.MOTD);
+ }
+ NetPlay.MOTD = NULL;
+ NETdeleteQueue();
SOCKETshutdown();
if (NetPlay.bComms && NetPlay.isUPNP)
@@ -1,5 +1,5 @@
-#include "netqueue.h"
#include "lib/framework/frame.h"
+#include "netqueue.h"
// See comments in netqueue.h.
@@ -1,8 +1,7 @@
#ifndef _NET_QUEUE_H_
#define _NET_QUEUE_H_
-#include "lib/framework/types.h"
-
+#include "lib/framework/frame.h"
#include <vector>
#include <list>
#include <deque>
@@ -420,6 +420,18 @@ void NETinitQueue(NETQUEUE queue)
}
}
+void NETdeleteQueue(void)
+{
+ for (int i = 0; i < MAX_PLAYERS; ++i)
+ {
+ delete pairQueue(NETnetQueue(i));
+ delete gameQueues[i];
+ }
+
+ delete broadcastQueue;
+
+}
+
void NETsetNoSendOverNetwork(NETQUEUE queue)
{
sendQueue(queue)->setWillNeverGetMessagesForNet(); // Will not be sending over net.
@@ -64,7 +64,7 @@ NetMessage const *NETgetMessage(NETQUEUE queue);///< Returns the current message
void NETinitQueue(NETQUEUE queue); ///< Allocates the queue. Deletes the old queue, if there was one. Avoids a crash on NULL pointer deference when trying to use the queue.
void NETsetNoSendOverNetwork(NETQUEUE queue); ///< Used to mark that a game queue should not be sent over the network (for example, if it is being sent to us, instead).
void NETmoveQueue(NETQUEUE src, NETQUEUE dst); ///< Used for moving the tmpQueue to a netQueue, once a newly-connected client is assigned a player number.
-
+void NETdeleteQueue(void); ///< Delete queues for cleanup
void NETbeginEncode(NETQUEUE queue, uint8_t type);
void NETbeginDecode(NETQUEUE queue, uint8_t type);
bool NETend(void);
View
@@ -39,6 +39,7 @@
#include "order.h"
#include "projectile.h"
#include "transporter.h"
+#include "mission.h"
#define GetRadius(x) ((x)->sradius)
@@ -531,13 +532,17 @@ static void displayCompObj(DROID *psDroid, bool bButton)
}
else
{
- MAPTILE *psTile = worldTile(psDroid->pos.x, psDroid->pos.y);
pieFlag = pie_SHADOW;
- if (psTile->jammerBits & alliancebits[psDroid->player])
+ brightness = pal_SetBrightness(psDroid->illumination);
+ // NOTE: Beware of transporters that are offscreen, on a mission! We should *not* be checking tiles at this point in time!
+ if (psDroid->droidType != DROID_TRANSPORTER && !missionIsOffworld())
{
- pieFlag |= pie_ECM;
+ MAPTILE *psTile = worldTile(psDroid->pos.x, psDroid->pos.y);
+ if (psTile->jammerBits & alliancebits[psDroid->player])
+ {
+ pieFlag |= pie_ECM;
+ }
}
- brightness = pal_SetBrightness(psDroid->illumination);
}
/* set default components transparent */
View
@@ -1488,37 +1488,11 @@ bool loadDroidWeapons(const char *pWeaponData, UDWORD bufferSize)
for (unsigned i = 0; i < table.size(); ++i)
{
LineView line(table, i);
-
- DROID_TEMPLATE *pTemplate;
std::string templateName = line.s(0);
- for (int player = 0; player < MAX_PLAYERS + 2; ++player)
+ for (int player = 0; player < MAX_PLAYERS ; ++player)
{
- if (player < MAX_PLAYERS) // a player
- {
- if (!isHumanPlayer(player))
- {
- continue; // no need to add to AIs, they use the static list
- }
- pTemplate = getTemplateFromUniqueName(templateName.c_str(), player);
- }
- else if (player == MAX_PLAYERS) // special exception - the static list
- {
- // Add weapons to static list
- pTemplate = getTemplateFromTranslatedNameNoPlayer(templateName.c_str());
- }
- else // Special exception - the local UI list.
- {
- pTemplate = NULL;
- for (std::list<DROID_TEMPLATE>::iterator j = localTemplates.begin(); j != localTemplates.end(); ++j)
- {
- if (j->pName == templateName)
- {
- pTemplate = &*j;
- break;
- }
- }
- }
+ DROID_TEMPLATE *pTemplate = getTemplateFromUniqueName(templateName.c_str(), player);
/* if Template not found - try default design */
if (!pTemplate)
@@ -1547,6 +1521,20 @@ bool loadDroidWeapons(const char *pWeaponData, UDWORD bufferSize)
//check valid weapon/propulsion
ASSERT_OR_RETURN(false, pTemplate->storeCount <= pTemplate->numWeaps, "Allocating more weapons than allowed for Template %s", templateName.c_str());
ASSERT_OR_RETURN(false, checkValidWeaponForProp(pTemplate), "Weapon is invalid for air propulsion for template %s", templateName.c_str());
+ if (player == selectedPlayer) // FIXME: can you say hack? Why don't we make a list on demmand ? This *will* break on player change!
+ {
+ DROID_TEMPLATE *pUITemplate = NULL;
+ for (std::list<DROID_TEMPLATE>::iterator j = localTemplates.begin(); j != localTemplates.end(); ++j)
+ {
+ if (j->pName == templateName)
+ {
+ pUITemplate = &*j;
+ // update UI template as well (it already passed the checks above)
+ pUITemplate->asWeaps[pTemplate->storeCount] = incWpn;
+ break;
+ }
+ }
+ }
pTemplate->storeCount++;
}
}
View
@@ -244,7 +244,8 @@ static void startSinglePlayerMenu(void)
addTextButton(FRONTEND_NEWGAME, FRONTEND_POS2X,FRONTEND_POS2Y,_("New Campaign") , WBUT_TXTCENTRE);
addTextButton(FRONTEND_SKIRMISH, FRONTEND_POS3X,FRONTEND_POS3Y, _("Start Skirmish Game"), WBUT_TXTCENTRE);
addTextButton(FRONTEND_CHALLENGES, FRONTEND_POS4X, FRONTEND_POS4Y, _("Challenges"), WBUT_TXTCENTRE);
- addTextButton(FRONTEND_LOADGAME, FRONTEND_POS5X,FRONTEND_POS5Y, _("Load Game"), WBUT_TXTCENTRE);
+ addTextButton(FRONTEND_LOADGAME_MISSION, FRONTEND_POS5X,FRONTEND_POS5Y, _("Load Campaign Game"), WBUT_TXTCENTRE);
+ addTextButton(FRONTEND_LOADGAME_SKIRMISH, FRONTEND_POS6X,FRONTEND_POS6Y, _("Load Skirmish Game"), WBUT_TXTCENTRE);
addSideText (FRONTEND_SIDETEXT ,FRONTEND_SIDEX,FRONTEND_SIDEY,_("SINGLE PLAYER"));
addMultiBut(psWScreen, FRONTEND_BOTFORM, FRONTEND_QUIT, 10, 10, 30, 29, P_("menu", "Return"), IMAGE_RETURN, IMAGE_RETURN_HI, IMAGE_RETURN_HI);
@@ -317,9 +318,14 @@ bool runSinglePlayerMenu(void)
frontEndNewGame();
break;
- case FRONTEND_LOADGAME:
+ case FRONTEND_LOADGAME_MISSION:
SPinit();
- addLoadSave(LOAD_FRONTEND, _("Load Saved Game")); // change mode when loadsave returns
+ addLoadSave(LOAD_FRONTEND_MISSION, _("Load Campaign Saved Game")); // change mode when loadsave returns
+ break;
+
+ case FRONTEND_LOADGAME_SKIRMISH:
+ SPinit();
+ addLoadSave(LOAD_FRONTEND_SKIRMISH, _("Load Skirmish Saved Game")); // change mode when loadsave returns
break;
case FRONTEND_SKIRMISH:
@@ -400,11 +406,13 @@ bool runMultiPlayerMenu(void)
ingame.bHostSetup = true;
bMultiPlayer = true;
bMultiMessages = true;
+ NETinit(true);
game.type = SKIRMISH; // needed?
lastTitleMode = MULTI;
changeTitleMode(MULTIOPTION);
break;
case FRONTEND_JOIN:
+ NETinit(true);
ingame.bHostSetup = false;
if (getLobbyError() != ERROR_INVALID)
{
View
@@ -172,7 +172,8 @@ enum
FRONTEND_QUIT,
FRONTEND_FASTPLAY, //tutorial menu option
FRONTEND_NEWGAME = 20200, // single player (menu)
- FRONTEND_LOADGAME,
+ FRONTEND_LOADGAME_MISSION,
+ FRONTEND_LOADGAME_SKIRMISH,
FRONTEND_SKIRMISH,
FRONTEND_CHALLENGES,
FRONTEND_HOST = 20300, //multiplayer menu options
View
@@ -5519,28 +5519,31 @@ bool writeTemplateFile(const char *pFileName)
}
for (int player = 0; player < MAX_PLAYERS; player++)
{
- for (DROID_TEMPLATE *psCurr = apsDroidTemplates[player]; psCurr != NULL; psCurr = psCurr->psNext)
- {
- ini.beginGroup("template_" + QString::number(psCurr->multiPlayerID));
- ini.setValue("name", psCurr->aName);
- ini.setValue("ref", psCurr->ref);
- ini.setValue("droidType", psCurr->droidType);
- ini.setValue("multiPlayerID", psCurr->multiPlayerID);
- setPlayer(ini, player);
- ini.setValue("body", (asBodyStats + psCurr->asParts[COMP_BODY])->pName);
- ini.setValue("propulsion", (asPropulsionStats + psCurr->asParts[COMP_PROPULSION])->pName);
- ini.setValue("brain", (asBrainStats + psCurr->asParts[COMP_BRAIN])->pName);
- ini.setValue("repair", (asRepairStats + psCurr->asParts[COMP_REPAIRUNIT])->pName);
- ini.setValue("ecm", (asECMStats + psCurr->asParts[COMP_ECM])->pName);
- ini.setValue("sensor", (asSensorStats + psCurr->asParts[COMP_SENSOR])->pName);
- ini.setValue("construct", (asConstructStats + psCurr->asParts[COMP_CONSTRUCT])->pName);
- ini.setValue("weapons", psCurr->numWeaps);
- ini.setValue("enabled", psCurr->enabled);
- for (int j = 0; j < psCurr->numWeaps; j++)
+ if (apsDroidLists[player] || apsStructLists[player]) // only write out templates of players that are still 'alive'
+ {
+ for (DROID_TEMPLATE *psCurr = apsDroidTemplates[player]; psCurr != NULL; psCurr = psCurr->psNext)
{
- ini.setValue("weapon/" + QString::number(j + 1), (asWeaponStats + psCurr->asWeaps[j])->pName);
+ ini.beginGroup("template_" + QString::number(psCurr->multiPlayerID) + "_player" + QString::number(player));
+ ini.setValue("name", psCurr->aName);
+ ini.setValue("ref", psCurr->ref);
+ ini.setValue("droidType", psCurr->droidType);
+ ini.setValue("multiPlayerID", psCurr->multiPlayerID);
+ setPlayer(ini, player);
+ ini.setValue("body", (asBodyStats + psCurr->asParts[COMP_BODY])->pName);
+ ini.setValue("propulsion", (asPropulsionStats + psCurr->asParts[COMP_PROPULSION])->pName);
+ ini.setValue("brain", (asBrainStats + psCurr->asParts[COMP_BRAIN])->pName);
+ ini.setValue("repair", (asRepairStats + psCurr->asParts[COMP_REPAIRUNIT])->pName);
+ ini.setValue("ecm", (asECMStats + psCurr->asParts[COMP_ECM])->pName);
+ ini.setValue("sensor", (asSensorStats + psCurr->asParts[COMP_SENSOR])->pName);
+ ini.setValue("construct", (asConstructStats + psCurr->asParts[COMP_CONSTRUCT])->pName);
+ ini.setValue("weapons", psCurr->numWeaps);
+ ini.setValue("enabled", psCurr->enabled);
+ for (int j = 0; j < psCurr->numWeaps; j++)
+ {
+ ini.setValue("weapon/" + QString::number(j + 1), (asWeaponStats + psCurr->asWeaps[j])->pName);
+ }
+ ini.endGroup();
}
- ini.endGroup();
}
}
return true;
View
@@ -269,10 +269,20 @@ static bool _intAddInGameOptions(void)
if ((!bMultiPlayer || (NetPlay.bComms == 0)) && !bInTutorial)
{
- // add 'load'
- addIGTextButton(INTINGAMEOP_LOAD, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
- // add 'save'
- addIGTextButton(INTINGAMEOP_SAVE, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
+ if (!bMultiPlayer)
+ {
+ // add 'load'
+ addIGTextButton(INTINGAMEOP_LOAD_MISSION, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
+ // add 'save'
+ addIGTextButton(INTINGAMEOP_SAVE_MISSION, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
+ }
+ else
+ {
+ // add 'load'
+ addIGTextButton(INTINGAMEOP_LOAD_SKIRMISH, INTINGAMEOP_1_X, INTINGAMEOP_3_Y, INTINGAMEOP_OP_W, _("Load Game"), OPALIGN);
+ // add 'save'
+ addIGTextButton(INTINGAMEOP_SAVE_SKIRMISH, INTINGAMEOP_1_X, INTINGAMEOP_4_Y, INTINGAMEOP_OP_W, _("Save Game"), OPALIGN);
+ }
}
intMode = INT_INGAMEOP; // change interface mode.
@@ -489,15 +499,21 @@ void intProcessInGameOptions(UDWORD id)
// addConsoleMessage(_("GAME SAVED!"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
// }
// break;
- case INTINGAMEOP_LOAD:
+ case INTINGAMEOP_LOAD_MISSION:
intCloseInGameOptions(true, false);
- addLoadSave(LOAD_INGAME, _("Load Saved Game")); // change mode when loadsave returns
+ addLoadSave(LOAD_INGAME_MISSION, _("Load Campaign Saved Game")); // change mode when loadsave returns
break;
- case INTINGAMEOP_SAVE:
+ case INTINGAMEOP_LOAD_SKIRMISH:
intCloseInGameOptions(true, false);
- addLoadSave(SAVE_INGAME, _("Save Game"));
+ addLoadSave(LOAD_INGAME_SKIRMISH, _("Load Skirmish Saved Game")); // change mode when loadsave returns
break;
-
+ case INTINGAMEOP_SAVE_MISSION:
+ intCloseInGameOptions(true, false);
+ addLoadSave(SAVE_INGAME_MISSION, _("Save Campaign Game"));
+ break;
+ case INTINGAMEOP_SAVE_SKIRMISH:
+ intCloseInGameOptions(true, false);
+ addLoadSave(SAVE_INGAME_SKIRMISH, _("Save Skirmish Game"));
// GAME OPTIONS KEYS
case INTINGAMEOP_FXVOL:
case INTINGAMEOP_3DFXVOL:
View
@@ -83,8 +83,10 @@ enum
INTINGAMEOP_QUIT = INTINGAMEOP + 1,
INTINGAMEOP_QUIT_CONFIRM, ///< The all important quit button
INTINGAMEOP_RESUME,
- INTINGAMEOP_LOAD,
- INTINGAMEOP_SAVE,
+ INTINGAMEOP_LOAD_MISSION,
+ INTINGAMEOP_LOAD_SKIRMISH,
+ INTINGAMEOP_SAVE_MISSION,
+ INTINGAMEOP_SAVE_SKIRMISH,
INTINGAMEOP_OPTIONS,
INTINGAMEOP_FXVOL,
INTINGAMEOP_FXVOL_S,
Oops, something went wrong.

0 comments on commit 4879779

Please sign in to comment.