use IsNetworkGame() define for NetworkFildes == (Socket)-1

This commit is contained in:
nehalmistry 2004-03-27 05:20:38 +00:00
parent 84e5a57730
commit 3866cd6810
9 changed files with 51 additions and 49 deletions

View file

@ -50,6 +50,8 @@
#define MaxNetworkCommands 9 /// Max Commands In A Packet
#define IsNetworkGame() (NetworkFildes != (Socket)-1)
/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/

View file

@ -1002,7 +1002,7 @@ global void MultiPlayerReplayEachCycle(void)
*/
global void SendCommandStopUnit(Unit* unit)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("stop", unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
CommandStopUnit(unit);
} else {
@ -1018,7 +1018,7 @@ global void SendCommandStopUnit(Unit* unit)
*/
global void SendCommandStandGround(Unit* unit, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("stand-ground", unit, flush, -1, -1, NoUnitP, NULL, -1);
CommandStandGround(unit, flush);
} else {
@ -1035,7 +1035,7 @@ global void SendCommandStandGround(Unit* unit, int flush)
*/
global void SendCommandFollow(Unit* unit, Unit* dest, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("follow", unit, flush, -1, -1, dest, NULL, -1);
CommandFollow(unit, dest, flush);
} else {
@ -1053,7 +1053,7 @@ global void SendCommandFollow(Unit* unit, Unit* dest, int flush)
*/
global void SendCommandMove(Unit* unit, int x, int y, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("move", unit, flush, x, y, NoUnitP, NULL, -1);
CommandMove(unit, x, y, flush);
} else {
@ -1072,7 +1072,7 @@ global void SendCommandMove(Unit* unit, int x, int y, int flush)
*/
global void SendCommandRepair(Unit* unit, int x, int y, Unit* dest, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("repair", unit, flush, x, y, dest, NULL, -1);
CommandRepair(unit, x, y, dest, flush);
} else {
@ -1091,7 +1091,7 @@ global void SendCommandRepair(Unit* unit, int x, int y, Unit* dest, int flush)
*/
global void SendCommandAttack(Unit* unit, int x, int y, Unit* attack, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("attack", unit, flush, x, y, attack, NULL, -1);
CommandAttack(unit, x, y, attack, flush);
} else {
@ -1109,7 +1109,7 @@ global void SendCommandAttack(Unit* unit, int x, int y, Unit* attack, int flush)
*/
global void SendCommandAttackGround(Unit* unit, int x, int y, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("attack-ground", unit, flush, x, y, NoUnitP, NULL, -1);
CommandAttackGround(unit, x, y, flush);
} else {
@ -1127,7 +1127,7 @@ global void SendCommandAttackGround(Unit* unit, int x, int y, int flush)
*/
global void SendCommandPatrol(Unit* unit, int x, int y, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("patrol", unit, flush, x, y, NoUnitP, NULL, -1);
CommandPatrolUnit(unit, x, y, flush);
} else {
@ -1146,7 +1146,7 @@ global void SendCommandPatrol(Unit* unit, int x, int y, int flush)
*/
global void SendCommandBoard(Unit* unit, int x, int y, Unit* dest, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("board", unit, flush, x, y, dest, NULL, -1);
CommandBoard(unit, dest, flush);
} else {
@ -1165,7 +1165,7 @@ global void SendCommandBoard(Unit* unit, int x, int y, Unit* dest, int flush)
*/
global void SendCommandUnload(Unit* unit, int x, int y, Unit* what, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("unload", unit, flush, x, y, what, NULL, -1);
CommandUnload(unit, x, y, what, flush);
} else {
@ -1185,7 +1185,7 @@ global void SendCommandUnload(Unit* unit, int x, int y, Unit* what, int flush)
global void SendCommandBuildBuilding(Unit* unit, int x, int y,
UnitType* what, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("build", unit, flush, x, y, NoUnitP, what->Ident, -1);
CommandBuildBuilding(unit, x, y, what, flush);
} else {
@ -1202,7 +1202,7 @@ global void SendCommandBuildBuilding(Unit* unit, int x, int y,
global void SendCommandDismiss(Unit* unit)
{
// FIXME: currently unit and worker are same?
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("dismiss", unit, FlushCommands, -1, -1, NULL, NULL, -1);
CommandDismiss(unit);
} else {
@ -1221,7 +1221,7 @@ global void SendCommandDismiss(Unit* unit)
*/
global void SendCommandResourceLoc(Unit* unit, int x, int y, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("resource-loc", unit, flush, x, y, NoUnitP, NULL, -1);
CommandResourceLoc(unit, x, y, flush);
} else {
@ -1238,7 +1238,7 @@ global void SendCommandResourceLoc(Unit* unit, int x, int y, int flush)
*/
global void SendCommandResource(Unit* unit, Unit* dest, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("resource", unit, flush, -1, -1, dest, NULL, -1);
CommandResource(unit, dest, flush);
} else {
@ -1255,7 +1255,7 @@ global void SendCommandResource(Unit* unit, Unit* dest, int flush)
*/
global void SendCommandReturnGoods(Unit* unit, Unit* goal, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("return", unit, flush, -1, -1, goal, NULL, -1);
CommandReturnGoods(unit, goal, flush);
} else {
@ -1272,7 +1272,7 @@ global void SendCommandReturnGoods(Unit* unit, Unit* goal, int flush)
*/
global void SendCommandTrainUnit(Unit* unit, UnitType* what, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("train", unit, flush, -1, -1, NoUnitP, what->Ident, -1);
CommandTrainUnit(unit, what, flush);
} else {
@ -1289,7 +1289,7 @@ global void SendCommandTrainUnit(Unit* unit, UnitType* what, int flush)
*/
global void SendCommandCancelTraining(Unit* unit, int slot, const UnitType* type)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("cancel-train", unit, FlushCommands, -1, -1, NoUnitP,
type ? type->Ident : NULL, slot);
CommandCancelTraining(unit, slot, type);
@ -1308,7 +1308,7 @@ global void SendCommandCancelTraining(Unit* unit, int slot, const UnitType* type
*/
global void SendCommandUpgradeTo(Unit* unit, UnitType* what, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("upgrade-to", unit, flush, -1, -1, NoUnitP, what->Ident, -1);
CommandUpgradeTo(unit, what, flush);
} else {
@ -1323,7 +1323,7 @@ global void SendCommandUpgradeTo(Unit* unit, UnitType* what, int flush)
*/
global void SendCommandCancelUpgradeTo(Unit* unit)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("cancel-upgrade-to", unit, FlushCommands,
-1, -1, NoUnitP, NULL, -1);
CommandCancelUpgradeTo(unit);
@ -1342,7 +1342,7 @@ global void SendCommandCancelUpgradeTo(Unit* unit)
*/
global void SendCommandResearch(Unit* unit, Upgrade* what, int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("research", unit, flush, -1, -1, NoUnitP, what->Ident, -1);
CommandResearch(unit, what, flush);
} else {
@ -1358,7 +1358,7 @@ global void SendCommandResearch(Unit* unit, Upgrade* what, int flush)
*/
global void SendCommandCancelResearch(Unit* unit)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("cancel-research", unit, FlushCommands, -1, -1, NoUnitP, NULL, -1);
CommandCancelResearch(unit);
} else {
@ -1380,7 +1380,7 @@ global void SendCommandCancelResearch(Unit* unit)
global void SendCommandSpellCast(Unit* unit, int x, int y, Unit* dest, int spellid,
int flush)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("spell-cast", unit, flush, x, y, dest, NULL, spellid);
CommandSpellCast(unit, x, y, dest, SpellTypeTable[spellid], flush);
} else {
@ -1398,7 +1398,7 @@ global void SendCommandSpellCast(Unit* unit, int x, int y, Unit* dest, int spell
*/
global void SendCommandAutoSpellCast(Unit* unit, int spellid, int on)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
CommandLog("auto-spell-cast", unit, FlushCommands, on, -1, NoUnitP,
NULL, spellid);
CommandAutoSpellCast(unit, spellid, on);
@ -1417,7 +1417,7 @@ global void SendCommandAutoSpellCast(Unit* unit, int spellid, int on)
*/
global void SendCommandDiplomacy(int player, int state, int opponent)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
switch (state) {
case DiplomacyNeutral:
CommandLog("diplomacy", NoUnitP, 0, player, opponent,
@ -1452,7 +1452,7 @@ global void SendCommandDiplomacy(int player, int state, int opponent)
*/
global void SendCommandSharedVision(int player, int state, int opponent)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
if (state == 0) {
CommandLog("shared-vision", NoUnitP, 0, player, opponent,
NoUnitP, "0", -1);

View file

@ -459,7 +459,7 @@ global void InitNetwork1(void)
*/
global void ExitNetwork1(void)
{
if (NetworkFildes == (Socket)-1) { // No network running
if (!IsNetworkGame()) { // No network running
return;
}
#ifdef DEBUG
@ -754,7 +754,7 @@ global void NetworkEvent(void)
int allowed;
unsigned long n;
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
NetworkInSync = 1;
return;
}

View file

@ -269,7 +269,7 @@ local void DrawMenuButtonArea(void)
TheUI.MenuPanel.Graphic->Height,
TheUI.MenuPanelX, TheUI.MenuPanelY);
}
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
if (TheUI.MenuButton.X != -1) {
//FIX ME: Transparent flag, 3rd param, has been hardcoded.
DrawMenuButton(TheUI.MenuButton.Button,
@ -678,7 +678,7 @@ global void UpdateDisplay(void)
}
}
if (MustRedraw & RedrawMenuButton) {
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
if (TheUI.MenuButton.X != -1) {
InvalidateAreaAndCheckCursor(
TheUI.MenuButton.X, TheUI.MenuButton.Y,
@ -801,7 +801,7 @@ global void GameMainLoop(void)
showtip = 0;
RealVideoSyncSpeed = VideoSyncSpeed;
if (NetworkFildes == (Socket)-1) { // Don't show them for net play
if (!IsNetworkGame()) { // Don't show them for net play
showtip = ShowTips;
}

View file

@ -1270,7 +1270,7 @@ global void LoadPud(const char* pud,WorldMap* map)
Players[o].Type != PlayerComputer) ) {
pawn:
if (t != WC_UnitGoldMine && t != WC_UnitOilPatch) {
if (NetworkFildes == (Socket)-1
if (!IsNetworkGame()
&& ReplayGameType != ReplayMultiPlayer
&& o == ThisPlayer->Player) {
s = GameSettings.Presets[0].Race;

View file

@ -170,7 +170,7 @@ global int ButtonCheckNetwork(const Unit* unit __attribute__((unused)),
global int ButtonCheckNoNetwork(const Unit* unit __attribute__((unused)),
const ButtonAction* button __attribute__((unused)))
{
return NetworkFildes == (Socket)-1;
return !IsNetworkGame();
}
/**

View file

@ -292,7 +292,7 @@ local void UiToggleMusic(void)
*/
global void UiTogglePause(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused ^= 1;
if (GamePaused) {
SetStatusLine("Game Paused");
@ -307,7 +307,7 @@ global void UiTogglePause(void)
*/
local void UiEnterMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -319,7 +319,7 @@ local void UiEnterMenu(void)
*/
local void UiEnterHelpMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -331,7 +331,7 @@ local void UiEnterHelpMenu(void)
*/
local void UiEnterOptionsMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -343,7 +343,7 @@ local void UiEnterOptionsMenu(void)
*/
local void UiEnterSoundOptionsMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -355,7 +355,7 @@ local void UiEnterSoundOptionsMenu(void)
*/
local void UiEnterSpeedOptionsMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -367,7 +367,7 @@ local void UiEnterSpeedOptionsMenu(void)
*/
local void UiEnterPreferencesOptionsMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -384,7 +384,7 @@ local void UiEnterSaveGameMenu(void)
return;
}
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -401,7 +401,7 @@ local void UiEnterLoadGameMenu(void)
return;
}
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -413,7 +413,7 @@ local void UiEnterLoadGameMenu(void)
*/
local void UiExitConfirmMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -425,7 +425,7 @@ local void UiExitConfirmMenu(void)
*/
local void UiQuitToMenuConfirmMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -437,7 +437,7 @@ local void UiQuitToMenuConfirmMenu(void)
*/
local void UiRestartConfirmMenu(void)
{
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}
@ -1017,7 +1017,7 @@ local int InputKey(int key)
}
} else
#endif
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
if (!GameObserve && !GamePaused) {
int ret;
ret = HandleCheats(Input);

View file

@ -2165,7 +2165,7 @@ local void PreferencesInit(Menuitem* mi __attribute__((unused)))
}
// Not available in net games or replays
if (NetworkFildes == (Socket)-1 && ReplayGameType == ReplayNone) {
if (!IsNetworkGame() && ReplayGameType == ReplayNone) {
menu->Items[1].flags = MI_ENABLED;
} else {
menu->Items[1].flags = MI_DISABLED;
@ -2243,7 +2243,7 @@ local void EndScenarioMenu(void)
Menu* menu;
menu = FindMenu("menu-end-scenario");
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
menu->Items[1].flags = MI_ENABLED;
} else {
menu->Items[1].flags = MI_DISABLED;

View file

@ -387,7 +387,7 @@ local void HandleMouseOn(int x, int y)
//
// Handle buttons
//
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
if (TheUI.MenuButton.X != -1 && !BigMapMode) {
if (x >= TheUI.MenuButton.X &&
x < TheUI.MenuButton.X + TheUI.MenuButton.Width &&
@ -1689,7 +1689,7 @@ global void UIHandleButtonUp(unsigned button)
(ButtonUnderCursor == ButtonUnderMenu ||
ButtonUnderCursor == ButtonUnderNetworkMenu)) {
// FIXME: Not if, in input mode.
if (NetworkFildes == (Socket)-1) {
if (!IsNetworkGame()) {
GamePaused = 1;
SetStatusLine("Game Paused");
}