[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src clone/clone.c clone/mainloop.c cl...
From: |
Jimmy Salmon |
Subject: |
[Stratagus-CVS] stratagus/src clone/clone.c clone/mainloop.c cl... |
Date: |
Mon, 29 Sep 2003 22:53:04 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Jimmy Salmon <address@hidden> 03/09/29 22:53:03
Modified files:
src/clone : clone.c mainloop.c pud.c
src/game : game.c
src/include : net_lowlevel.h network.h
src/network : commands.c lowlevel.c network.c
src/ui : button_checks.c interface.c menus.c mouse.c
src/video : sdl.c
Log message:
Added Socket typedef
Patches:
Index: stratagus/src/clone/clone.c
diff -u stratagus/src/clone/clone.c:1.206 stratagus/src/clone/clone.c:1.207
--- stratagus/src/clone/clone.c:1.206 Sun Sep 28 21:44:38 2003
+++ stratagus/src/clone/clone.c Mon Sep 29 22:53:01 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: clone.c,v 1.206 2003/09/29 01:44:38 mr-russ Exp $
+// $Id: clone.c,v 1.207 2003/09/30 02:53:01 jsalmon3 Exp $
//@{
@@ -1065,7 +1065,7 @@
//
// Network part 1 (port set-up)
//
- if( NetworkFildes!=-1 ) {
+ if( NetworkFildes!=(Socket)-1 ) {
ExitNetwork1();
}
InitNetwork1();
@@ -1110,7 +1110,7 @@
}
strcpy(CurrentMapPath,filename);
}
- if( NetworkFildes!=-1 && NetPlayers<2 ) {
+ if( NetworkFildes!=(Socket)-1 && NetPlayers<2 ) {
ExitNetwork1();
}
Index: stratagus/src/clone/mainloop.c
diff -u stratagus/src/clone/mainloop.c:1.143
stratagus/src/clone/mainloop.c:1.144
--- stratagus/src/clone/mainloop.c:1.143 Sat Sep 27 02:16:36 2003
+++ stratagus/src/clone/mainloop.c Mon Sep 29 22:53:01 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: mainloop.c,v 1.143 2003/09/27 06:16:36 mr-russ Exp $
+// $Id: mainloop.c,v 1.144 2003/09/30 02:53:01 jsalmon3 Exp $
//@{
@@ -272,7 +272,7 @@
TheUI.MenuButtonGraphic.Graphic->Height,
TheUI.MenuButtonGraphicX, TheUI.MenuButtonGraphicY);
}
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
if( TheUI.MenuButton.X!=-1 ) {
DrawMenuButton(TheUI.MenuButton.Button,
(ButtonAreaUnderCursor==ButtonAreaMenu
@@ -656,7 +656,7 @@
}
}
if(MustRedraw&RedrawMenuButton ) {
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
if( TheUI.MenuButton.X!=-1 ) {
InvalidateAreaAndCheckCursor(
TheUI.MenuButton.X,TheUI.MenuButton.Y,
@@ -778,7 +778,7 @@
showtip=0;
RealVideoSyncSpeed = VideoSyncSpeed;
- if( NetworkFildes==-1 ) { // Don't show them for net play
+ if( NetworkFildes==(Socket)-1 ) { // Don't show them for net play
showtip=ShowTips;
}
Index: stratagus/src/clone/pud.c
diff -u stratagus/src/clone/pud.c:1.109 stratagus/src/clone/pud.c:1.110
--- stratagus/src/clone/pud.c:1.109 Fri Sep 26 14:52:18 2003
+++ stratagus/src/clone/pud.c Mon Sep 29 22:53:01 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: pud.c,v 1.109 2003/09/26 18:52:18 jsalmon3 Exp $
+// $Id: pud.c,v 1.110 2003/09/30 02:53:01 jsalmon3 Exp $
//@{
@@ -46,6 +46,7 @@
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
#define DrawIcon WinDrawIcon
#define EndMenu WinEndMenu
+#include <winsock2.h>
#include <windows.h>
#undef DrawIcon
#undef EndMenu
@@ -1267,7 +1268,7 @@
Players[o].Type != PlayerComputer) ) {
pawn:
if (t != WC_UnitGoldMine && t != WC_UnitOilPatch) {
- if (NetworkFildes == -1
+ if (NetworkFildes == (Socket)-1
&& ReplayGameType != ReplayMultiPlayer
&& o == ThisPlayer->Player) {
s = GameSettings.Presets[0].Race;
Index: stratagus/src/game/game.c
diff -u stratagus/src/game/game.c:1.104 stratagus/src/game/game.c:1.105
--- stratagus/src/game/game.c:1.104 Fri Sep 26 20:23:39 2003
+++ stratagus/src/game/game.c Mon Sep 29 22:53:01 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: game.c,v 1.104 2003/09/27 00:23:39 jsalmon3 Exp $
+// $Id: game.c,v 1.105 2003/09/30 02:53:01 jsalmon3 Exp $
//@{
@@ -308,7 +308,7 @@
SyncHash = 0;
InitSyncRand();
- if (NetworkFildes != -1) { // Prepare network play
+ if (NetworkFildes != (Socket)-1) { // Prepare network play
DebugLevel0Fn("Client setup: Calling InitNetwork2\n");
InitNetwork2();
} else {
@@ -414,16 +414,14 @@
LoadUnitTypes();
LoadDecorations();
- IfDebug(
- DebugLevel0("Graphics uses %d bytes (%d KB, %d MB)\n"
- _C_ AllocatedGraphicMemory
- _C_ AllocatedGraphicMemory / 1024
- _C_ AllocatedGraphicMemory / 1024 / 1024);
- DebugLevel0("Compressed graphics uses %d bytes (%d KB, %d MB)\n"
- _C_ CompressedGraphicMemory
- _C_ CompressedGraphicMemory / 1024
- _C_ CompressedGraphicMemory / 1024 / 1024);
- );
+ DebugLevel0("Graphics uses %d bytes (%d KB, %d MB)\n" _C_
+ AllocatedGraphicMemory _C_
+ AllocatedGraphicMemory / 1024 _C_
+ AllocatedGraphicMemory / 1024 / 1024);
+ DebugLevel0("Compressed graphics uses %d bytes (%d KB, %d MB)\n" _C_
+ CompressedGraphicMemory _C_
+ CompressedGraphicMemory / 1024 _C_
+ CompressedGraphicMemory / 1024 / 1024);
CreateMinimap(); // create minimap for pud
InitMap(); // setup draw functions
@@ -442,16 +440,14 @@
MapUnitSounds();
#ifdef WITH_SOUND
- IfDebug(
- DebugLevel0("Sounds uses %d bytes (%d KB, %d MB)\n"
- _C_ AllocatedSoundMemory
- _C_ AllocatedSoundMemory / 1024
- _C_ AllocatedSoundMemory / 1024 / 1024);
- DebugLevel0("Compressed sounds uses %d bytes (%d KB, %d MB)\n"
- _C_ CompressedSoundMemory
- _C_ CompressedSoundMemory / 1024
- _C_ CompressedSoundMemory / 1024 / 1024);
- );
+ DebugLevel0("Sounds uses %d bytes (%d KB, %d MB)\n" _C_
+ AllocatedSoundMemory _C_
+ AllocatedSoundMemory / 1024 _C_
+ AllocatedSoundMemory / 1024 / 1024);
+ DebugLevel0("Compressed sounds uses %d bytes (%d KB, %d MB)\n" _C_
+ CompressedSoundMemory _C_
+ CompressedSoundMemory / 1024 _C_
+ CompressedSoundMemory / 1024 / 1024);
#endif
//
Index: stratagus/src/include/net_lowlevel.h
diff -u stratagus/src/include/net_lowlevel.h:1.28
stratagus/src/include/net_lowlevel.h:1.29
--- stratagus/src/include/net_lowlevel.h:1.28 Fri Jul 11 10:35:30 2003
+++ stratagus/src/include/net_lowlevel.h Mon Sep 29 22:53:01 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: net_lowlevel.h,v 1.28 2003/07/11 14:35:30 n0body Exp $
+// $Id: net_lowlevel.h,v 1.29 2003/09/30 02:53:01 jsalmon3 Exp $
#ifndef __NET_LOWLEVEL_H
#define __NET_LOWLEVEL_H
@@ -116,6 +116,12 @@
(int)(((ad) >> 24) & 0xff), (int)(((ad) >> 16) & 0xff), \
(int)(((ad) >> 8) & 0xff), (int)((ad) & 0xff)
+#ifdef USE_WIN32
+typedef SOCKET Socket;
+#else
+typedef int Socket;
+#endif
+
/*----------------------------------------------------------------------------
-- Declarations
----------------------------------------------------------------------------*/
@@ -140,34 +146,34 @@
/// Resolve host in name or or colon dot notation.
extern unsigned long NetResolveHost(const char* host);
/// Get local IP from network file descriptor
-extern int NetSocketAddr(const int sock);
+extern int NetSocketAddr(const Socket sock);
/// Open a UDP Socket port.
-extern int NetOpenUDP(int port);
+extern Socket NetOpenUDP(int port);
/// Open a TCP Socket port.
-extern int NetOpenTCP(int port);
+extern Socket NetOpenTCP(int port);
/// Close a UDP socket port.
-extern void NetCloseUDP(int sockfd);
+extern void NetCloseUDP(Socket sockfd);
/// Close a TCP socket port.
-extern void NetCloseTCP(int sockfd);
+extern void NetCloseTCP(Socket sockfd);
/// Set socket to non-blocking
-extern int NetSetNonBlocking(int sockfd);
+extern int NetSetNonBlocking(Socket sockfd);
/// Open a TCP connection.
-extern int NetConnectTCP(int sockfd,unsigned long addr,int port);
+extern int NetConnectTCP(Socket sockfd,unsigned long addr,int port);
/// Send through a UPD socket to a host:port.
-extern int NetSendUDP(int sockfd,unsigned long host,int port
+extern int NetSendUDP(Socket sockfd,unsigned long host,int port
,const void* buf,int len);
/// Send through a TCP socket
-extern int NetSendTCP(int sockfd,const void* buf,int len);
+extern int NetSendTCP(Socket sockfd,const void* buf,int len);
/// Wait for socket ready.
-extern int NetSocketReady(int sockfd,int timeout);
+extern int NetSocketReady(Socket sockfd,int timeout);
/// Receive from a UDP socket.
-extern int NetRecvUDP(int sockfd,void* buf,int len);
+extern int NetRecvUDP(Socket sockfd,void* buf,int len);
/// Receive from a TCP socket.
-extern int NetRecvTCP(int sockfd,void* buf,int len);
+extern int NetRecvTCP(Socket sockfd,void* buf,int len);
/// Listen for connections on a TCP socket
-extern int NetListenTCP(int sockfd);
+extern int NetListenTCP(Socket sockfd);
/// Accept a connection on a TCP socket
-extern int NetAcceptTCP(int sockfd);
+extern Socket NetAcceptTCP(Socket sockfd);
//@}
Index: stratagus/src/include/network.h
diff -u stratagus/src/include/network.h:1.40
stratagus/src/include/network.h:1.41
--- stratagus/src/include/network.h:1.40 Fri Sep 5 14:10:55 2003
+++ stratagus/src/include/network.h Mon Sep 29 22:53:02 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: network.h,v 1.40 2003/09/05 18:10:55 n0body Exp $
+// $Id: network.h,v 1.41 2003/09/30 02:53:02 jsalmon3 Exp $
#ifndef __NETWORK_H__
#define __NETWORK_H__
@@ -40,6 +40,7 @@
#include "unittype.h"
#include "unit.h"
#include "upgrade.h"
+#include "net_lowlevel.h"
/*----------------------------------------------------------------------------
-- Defines
@@ -165,7 +166,7 @@
----------------------------------------------------------------------------*/
extern int NetworkNumInterfaces; /// Network number of interfaces
-extern int NetworkFildes; /// Network file descriptor
+extern Socket NetworkFildes; /// Network file descriptor
extern int NetworkInSync; /// Network is in sync
extern int NetworkUpdates; /// Network update each # game cycles
extern int NetworkLag; /// Network lag (# game cycles)
Index: stratagus/src/network/commands.c
diff -u stratagus/src/network/commands.c:1.66
stratagus/src/network/commands.c:1.67
--- stratagus/src/network/commands.c:1.66 Thu Sep 18 07:59:21 2003
+++ stratagus/src/network/commands.c Mon Sep 29 22:53:02 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: commands.c,v 1.66 2003/09/18 11:59:21 mr-russ Exp $
+// $Id: commands.c,v 1.67 2003/09/30 02:53:02 jsalmon3 Exp $
//@{
@@ -145,8 +145,8 @@
fprintf(LogFile,"(replay-log\n");
fprintf(LogFile," 'comment\t\"Generated by Stratagus Version " VERSION
"\"\n");
fprintf(LogFile," 'comment\t\"Visit http://Stratagus.Org for more
information\"\n");
- fprintf(LogFile," 'comment\t\"$Id: commands.c,v 1.66 2003/09/18
11:59:21 mr-russ Exp $\"\n");
- if( NetworkFildes==-1 ) {
+ fprintf(LogFile," 'comment\t\"$Id: commands.c,v 1.67 2003/09/30
02:53:02 jsalmon3 Exp $\"\n");
+ if( NetworkFildes==(Socket)-1 ) {
fprintf(LogFile," 'type\t\"%s\"\n","single-player");
fprintf(LogFile," 'race\t%d\n",GameSettings.Presets[0].Race);
} else {
@@ -692,7 +692,7 @@
*/
global void SendCommandStopUnit(Unit* unit)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("stop",unit,FlushCommands,-1,-1,NoUnitP,NULL,-1);
CommandStopUnit(unit);
} else {
@@ -708,7 +708,7 @@
*/
global void SendCommandStandGround(Unit* unit,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("stand-ground",unit,flush,-1,-1,NoUnitP,NULL,-1);
CommandStandGround(unit,flush);
} else {
@@ -725,7 +725,7 @@
*/
global void SendCommandFollow(Unit* unit,Unit* dest,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("follow",unit,flush,-1,-1,dest,NULL,-1);
CommandFollow(unit,dest,flush);
} else {
@@ -743,7 +743,7 @@
*/
global void SendCommandMove(Unit* unit,int x,int y,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("move",unit,flush,x,y,NoUnitP,NULL,-1);
CommandMove(unit,x,y,flush);
} else {
@@ -762,7 +762,7 @@
*/
global void SendCommandRepair(Unit* unit,int x,int y,Unit* dest,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("repair",unit,flush,x,y,dest,NULL,-1);
CommandRepair(unit,x,y,dest,flush);
} else {
@@ -781,7 +781,7 @@
*/
global void SendCommandAttack(Unit* unit,int x,int y,Unit* attack,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("attack",unit,flush,x,y,attack,NULL,-1);
CommandAttack(unit,x,y,attack,flush);
} else {
@@ -799,7 +799,7 @@
*/
global void SendCommandAttackGround(Unit* unit,int x,int y,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("attack-ground",unit,flush,x,y,NoUnitP,NULL,-1);
CommandAttackGround(unit,x,y,flush);
} else {
@@ -817,7 +817,7 @@
*/
global void SendCommandPatrol(Unit* unit,int x,int y,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("patrol",unit,flush,x,y,NoUnitP,NULL,-1);
CommandPatrolUnit(unit,x,y,flush);
} else {
@@ -836,7 +836,7 @@
*/
global void SendCommandBoard(Unit* unit,int x,int y,Unit* dest,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("board",unit,flush,x,y,dest,NULL,-1);
CommandBoard(unit,dest,flush);
} else {
@@ -855,7 +855,7 @@
*/
global void SendCommandUnload(Unit* unit,int x,int y,Unit* what,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("unload",unit,flush,x,y,what,NULL,-1);
CommandUnload(unit,x,y,what,flush);
} else {
@@ -875,7 +875,7 @@
global void SendCommandBuildBuilding(Unit* unit,int x,int y
,UnitType* what,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("build",unit,flush,x,y,NoUnitP,what->Ident,-1);
CommandBuildBuilding(unit,x,y,what,flush);
} else {
@@ -892,7 +892,7 @@
global void SendCommandCancelBuilding(Unit* unit,Unit* worker)
{
// FIXME: currently unit and worker are same?
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("cancel-build",unit,FlushCommands,-1,-1,worker,NULL,-1);
CommandCancelBuilding(unit,worker);
} else {
@@ -911,7 +911,7 @@
*/
global void SendCommandResourceLoc(Unit* unit,int x,int y,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("resource-loc",unit,flush,x,y,NoUnitP,NULL,-1);
CommandResourceLoc(unit,x,y,flush);
} else {
@@ -928,7 +928,7 @@
*/
global void SendCommandResource(Unit* unit,Unit* dest,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("resource",unit,flush,-1,-1,dest,NULL,-1);
CommandResource(unit,dest,flush);
} else {
@@ -945,7 +945,7 @@
*/
global void SendCommandReturnGoods(Unit* unit,Unit* goal,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("return",unit,flush,-1,-1,goal,NULL,-1);
CommandReturnGoods(unit,goal,flush);
} else {
@@ -962,7 +962,7 @@
*/
global void SendCommandTrainUnit(Unit* unit,UnitType* what,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("train",unit,flush,-1,-1,NoUnitP,what->Ident,-1);
CommandTrainUnit(unit,what,flush);
} else {
@@ -979,7 +979,7 @@
*/
global void SendCommandCancelTraining(Unit* unit,int slot,const UnitType* type)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("cancel-train",unit,FlushCommands,-1,-1,NoUnitP,
type ? type->Ident : NULL,slot);
CommandCancelTraining(unit,slot,type);
@@ -998,7 +998,7 @@
*/
global void SendCommandUpgradeTo(Unit* unit,UnitType* what,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("upgrade-to",unit,flush,-1,-1,NoUnitP,what->Ident,-1);
CommandUpgradeTo(unit,what,flush);
} else {
@@ -1013,7 +1013,7 @@
*/
global void SendCommandCancelUpgradeTo(Unit* unit)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("cancel-upgrade-to",unit,FlushCommands
,-1,-1,NoUnitP,NULL,-1);
CommandCancelUpgradeTo(unit);
@@ -1032,7 +1032,7 @@
*/
global void SendCommandResearch(Unit* unit,Upgrade* what,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("research",unit,flush,-1,-1,NoUnitP,what->Ident,-1);
CommandResearch(unit,what,flush);
} else {
@@ -1048,7 +1048,7 @@
*/
global void SendCommandCancelResearch(Unit* unit)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("cancel-research",unit,FlushCommands,-1,-1,NoUnitP,NULL,-1);
CommandCancelResearch(unit);
} else {
@@ -1068,7 +1068,7 @@
*/
global void SendCommandDemolish(Unit* unit,int x,int y,Unit* attack,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("demolish",unit,flush,x,y,attack,NULL,-1);
CommandDemolish(unit,x,y,attack,flush);
} else {
@@ -1089,7 +1089,7 @@
global void SendCommandSpellCast(Unit* unit,int x,int y,Unit* dest,int spellid
,int flush)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("spell-cast",unit,flush,x,y,dest,NULL,spellid);
CommandSpellCast(unit,x,y,dest,SpellTypeById(spellid),flush);
} else {
@@ -1107,7 +1107,7 @@
*/
global void SendCommandAutoSpellCast(Unit* unit,int spellid,int on)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
CommandLog("auto-spell-cast",unit,FlushCommands,on,-1,NoUnitP
,NULL,spellid);
CommandAutoSpellCast(unit,on?SpellTypeById(spellid):NULL);
@@ -1126,7 +1126,7 @@
*/
global void SendCommandDiplomacy(int player,int state,int opponent)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
switch( state ) {
case DiplomacyNeutral:
CommandLog("diplomacy",NoUnitP,0,player,opponent,
@@ -1161,7 +1161,7 @@
*/
global void SendCommandSharedVision(int player,int state,int opponent)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
if( state==0 ) {
CommandLog("shared-vision",NoUnitP,0,player,opponent,
NoUnitP,"0",-1);
Index: stratagus/src/network/lowlevel.c
diff -u stratagus/src/network/lowlevel.c:1.34
stratagus/src/network/lowlevel.c:1.35
--- stratagus/src/network/lowlevel.c:1.34 Thu Sep 18 07:59:21 2003
+++ stratagus/src/network/lowlevel.c Mon Sep 29 22:53:02 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: lowlevel.c,v 1.34 2003/09/18 11:59:21 mr-russ Exp $
+// $Id: lowlevel.c,v 1.35 2003/09/30 02:53:02 jsalmon3 Exp $
//@{
@@ -161,7 +161,7 @@
**
** @param sockfd Socket fildes
*/
-global void NetCloseUDP(int sockfd)
+global void NetCloseUDP(Socket sockfd)
{
closesocket(sockfd);
}
@@ -171,7 +171,7 @@
**
** @param sockfd Socket fildes
*/
-global void NetCloseTCP(int sockfd)
+global void NetCloseTCP(Socket sockfd)
{
closesocket(sockfd);
}
@@ -200,7 +200,7 @@
**
** @param sockfd Socket fildes
*/
-global void NetCloseUDP(int sockfd)
+global void NetCloseUDP(Socket sockfd)
{
close(sockfd);
}
@@ -210,7 +210,7 @@
**
** @param sockfd Socket fildes
*/
-global void NetCloseTCP(int sockfd)
+global void NetCloseTCP(Socket sockfd)
{
close(sockfd);
}
@@ -225,7 +225,7 @@
** @return 0 for success, -1 for error
*/
#ifdef USE_WINSOCK
-global int NetSetNonBlocking(int sockfd)
+global int NetSetNonBlocking(Socket sockfd)
{
unsigned long opt;
@@ -233,7 +233,7 @@
return ioctlsocket(sockfd,FIONBIO,&opt);
}
#else
-global int NetSetNonBlocking(int sockfd)
+global int NetSetNonBlocking(Socket sockfd)
{
int flags;
@@ -282,7 +282,7 @@
// I also found a way for winsock1.1 (= win95), but
// that one was too complex to start with.. -> trouble
// Lookout for INTRFC.EXE on the MS web site...
-global int NetSocketAddr(const int sock)
+global int NetSocketAddr(const Socket sock)
{
INTERFACE_INFO localAddr[MAX_LOC_IP]; // Assume there will be no more
than MAX_LOC_IP interfaces
DWORD bytesReturned;
@@ -292,7 +292,7 @@
int numLocalAddr;
nif = 0;
- if (sock != -1) {
+ if (sock != (Socket)-1) {
wsError = WSAIoctl(sock, SIO_GET_INTERFACE_LIST, NULL, 0, &localAddr,
sizeof(localAddr), &bytesReturned, NULL, NULL);
if (wsError == SOCKET_ERROR) {
@@ -323,7 +323,7 @@
// ARI: I knew how to write this for a unix environment,
// but am quite certain that porting this can cause you
// trouble..
-global int NetSocketAddr(const int sock)
+global int NetSocketAddr(const Socket sock)
{
char buf[4096], *cp, *cplim;
struct ifconf ifc;
@@ -332,7 +332,7 @@
int i, nif;
nif = 0;
- if (sock != -1) {
+ if (sock != (Socket)-1) {
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
@@ -400,7 +400,7 @@
}
#else // } !unix
// Beos?? Mac??
-global int NetSocketAddr(const int sock)
+global int NetSocketAddr(const Socket sock)
{
NetLocalAddrs[0] = htonl(0x7f000001);
return 1;
@@ -415,9 +415,9 @@
**
** @return If success the socket fildes, -1 otherwise.
*/
-global int NetOpenUDP(int port)
+global Socket NetOpenUDP(int port)
{
- int sockfd;
+ Socket sockfd;
// open the socket
sockfd=socket(AF_INET, SOCK_DGRAM, 0);
@@ -453,14 +453,14 @@
**
** @return If success the socket fildes, -1 otherwise
*/
-global int NetOpenTCP(int port)
+global Socket NetOpenTCP(int port)
{
- int sockfd;
+ Socket sockfd;
sockfd=socket(AF_INET, SOCK_STREAM, 0);
DebugLevel3Fn(" socket %d\n" _C_ sockfd);
if( sockfd==INVALID_SOCKET ) {
- return -1;
+ return (Socket)-1;
}
// bind local port
if( port ) {
@@ -478,7 +478,7 @@
if( bind(sockfd,(struct sockaddr*)&sock_addr,sizeof(sock_addr))<0 ) {
fprintf(stderr,"Couldn't bind to local port\n");
NetCloseTCP(sockfd);
- return -1;
+ return (Socket)-1;
}
DebugLevel3Fn(" bind ok\n");
NetLastHost=sock_addr.sin_addr.s_addr;
@@ -497,7 +497,7 @@
**
** @return 0 if success, -1 if failure
*/
-global int NetConnectTCP(int sockfd,unsigned long addr,int port)
+global int NetConnectTCP(Socket sockfd,unsigned long addr,int port)
{
struct sockaddr_in sa;
#ifndef __BEOS__
@@ -535,7 +535,7 @@
**
** @return 1 if data is available, 0 if not, -1 if failure.
*/
-global int NetSocketReady(int sockfd,int timeout)
+global int NetSocketReady(Socket sockfd,int timeout)
{
int retval;
struct timeval tv;
@@ -591,7 +591,7 @@
**
** @return Number of bytes placed in buffer, or -1 if failure.
*/
-global int NetRecvUDP(int sockfd,void* buf,int len)
+global int NetRecvUDP(Socket sockfd,void* buf,int len)
{
int n;
int l;
@@ -624,7 +624,7 @@
**
** @return Number of bytes placed in buffer or -1 if failure.
*/
-global int NetRecvTCP(int sockfd,void* buf,int len)
+global int NetRecvTCP(Socket sockfd,void* buf,int len)
{
NetLastSocket=sockfd;
return recv(sockfd,buf,len,0);
@@ -641,7 +641,7 @@
**
** @return Number of bytes sent.
*/
-global int NetSendUDP(int sockfd,unsigned long host,int port
+global int NetSendUDP(Socket sockfd,unsigned long host,int port
,const void* buf,int len)
{
int n;
@@ -666,7 +666,7 @@
**
** @return Number of bytes sent.
*/
-global int NetSendTCP(int sockfd,const void* buf,int len)
+global int NetSendTCP(Socket sockfd,const void* buf,int len)
{
return send(sockfd,buf,len,0);
}
@@ -678,7 +678,7 @@
**
** @return 0 for success, -1 for error
*/
-global int NetListenTCP(int sockfd)
+global int NetListenTCP(Socket sockfd)
{
return listen(sockfd,PlayerMax);
}
@@ -690,7 +690,7 @@
**
** @return If success the new socket fildes, -1 otherwise.
*/
-global int NetAcceptTCP(int sockfd)
+global Socket NetAcceptTCP(Socket sockfd)
{
struct sockaddr_in sa;
int len;
Index: stratagus/src/network/network.c
diff -u stratagus/src/network/network.c:1.116
stratagus/src/network/network.c:1.117
--- stratagus/src/network/network.c:1.116 Thu Sep 18 07:59:21 2003
+++ stratagus/src/network/network.c Mon Sep 29 22:53:02 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: network.c,v 1.116 2003/09/18 11:59:21 mr-russ Exp $
+// $Id: network.c,v 1.117 2003/09/30 02:53:02 jsalmon3 Exp $
//@{
@@ -272,7 +272,7 @@
//----------------------------------------------------------------------------
global int NetworkNumInterfaces; /// Network number of interfaces
-global int NetworkFildes = -1; /// Network file descriptor
+global Socket NetworkFildes = -1; /// Network file descriptor
global int NetworkInSync = 1; /// Network is in sync
global int NetworkUpdates = 5; /// Network update each # game cycles
global int NetworkLag = 10; /// Network lag in # game cycles
@@ -432,7 +432,7 @@
port = NetworkPort;
for (i = 0; i < 10; ++i) {
NetworkFildes = NetOpenUDP(port + i);
- if (NetworkFildes != -1) {
+ if (NetworkFildes != (Socket)-1) {
break;
}
if (i == 9) {
@@ -483,7 +483,7 @@
*/
global void ExitNetwork1(void)
{
- if (NetworkFildes == -1) { // No network running
+ if (NetworkFildes == (Socket)-1) { // No network running
return;
}
#ifdef DEBUG
@@ -665,7 +665,7 @@
int i;
unsigned long n;
- if (NetworkFildes == -1) {
+ if (NetworkFildes == (Socket)-1) {
NetworkInSync = 1;
return;
}
@@ -882,7 +882,7 @@
const char *cp;
int n;
- if (NetworkFildes != -1) {
+ if (NetworkFildes != (Socket)-1) {
cp = msg;
n = strlen(msg);
while (n >= (int)sizeof(ncm->Text)) {
@@ -1152,7 +1152,7 @@
*/
global void NetworkCommands(void)
{
- if (NetworkFildes != -1) {
+ if (NetworkFildes != (Socket)-1) {
//
// Send messages to all clients (other players)
//
Index: stratagus/src/ui/button_checks.c
diff -u stratagus/src/ui/button_checks.c:1.11
stratagus/src/ui/button_checks.c:1.12
--- stratagus/src/ui/button_checks.c:1.11 Mon Sep 29 11:41:28 2003
+++ stratagus/src/ui/button_checks.c Mon Sep 29 22:53:02 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: button_checks.c,v 1.11 2003/09/29 15:41:28 jsalmon3 Exp $
+// $Id: button_checks.c,v 1.12 2003/09/30 02:53:02 jsalmon3 Exp $
//@{
@@ -162,7 +162,7 @@
global int ButtonCheckNetwork(const Unit* unit __attribute__((unused)),
const ButtonAction* button __attribute__((unused)))
{
- return NetworkFildes != -1;
+ return NetworkFildes != (Socket)-1;
}
/**
@@ -177,7 +177,7 @@
global int ButtonCheckNoNetwork(const Unit* unit __attribute__((unused)),
const ButtonAction* button __attribute__((unused)))
{
- return NetworkFildes == -1;
+ return NetworkFildes == (Socket)-1;
}
/**
Index: stratagus/src/ui/interface.c
diff -u stratagus/src/ui/interface.c:1.136 stratagus/src/ui/interface.c:1.137
--- stratagus/src/ui/interface.c:1.136 Fri Sep 5 14:10:56 2003
+++ stratagus/src/ui/interface.c Mon Sep 29 22:53:02 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: interface.c,v 1.136 2003/09/05 18:10:56 n0body Exp $
+// $Id: interface.c,v 1.137 2003/09/30 02:53:02 jsalmon3 Exp $
//@{
@@ -338,7 +338,7 @@
*/
local void UiEnterMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -350,7 +350,7 @@
*/
local void UiEnterHelpMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -362,7 +362,7 @@
*/
local void UiEnterOptionsMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -374,7 +374,7 @@
*/
local void UiEnterSoundOptionsMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -386,7 +386,7 @@
*/
local void UiEnterSpeedOptionsMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -398,7 +398,7 @@
*/
local void UiEnterPreferencesOptionsMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -411,11 +411,11 @@
local void UiEnterSaveGameMenu(void)
{
// Disable save menu in multiplayer and replays
- if (NetworkFildes != -1 || ReplayGameType != ReplayNone) {
+ if (NetworkFildes != (Socket)-1 || ReplayGameType != ReplayNone) {
return;
}
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -428,11 +428,11 @@
local void UiEnterLoadGameMenu(void)
{
// Disable load menu in multiplayer
- if (NetworkFildes != -1) {
+ if (NetworkFildes != (Socket)-1) {
return;
}
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -444,7 +444,7 @@
*/
local void UiExitConfirmMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -456,7 +456,7 @@
*/
local void UiQuitToMenuConfirmMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -468,7 +468,7 @@
*/
local void UiRestartConfirmMenu(void)
{
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
@@ -1121,7 +1121,7 @@
CommandLog("input",
NoUnitP,FlushCommands,-1,-1,NoUnitP,Input,-1);
CclCommand(Input);
}
- } else if (NetworkFildes==-1) {
+ } else if (NetworkFildes==(Socket)-1) {
if (!GameObserve && !GamePaused) {
int ret;
ret = HandleCheats(Input);
Index: stratagus/src/ui/menus.c
diff -u stratagus/src/ui/menus.c:1.558 stratagus/src/ui/menus.c:1.559
--- stratagus/src/ui/menus.c:1.558 Fri Sep 26 19:52:00 2003
+++ stratagus/src/ui/menus.c Mon Sep 29 22:53:02 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: menus.c,v 1.558 2003/09/26 23:52:00 mr-russ Exp $
+// $Id: menus.c,v 1.559 2003/09/30 02:53:02 jsalmon3 Exp $
//@{
@@ -1532,14 +1532,14 @@
local void GameMenuInit(Menuitem *mi __attribute__((unused)))
{
// Disable save menu in multiplayer and replays
- if (NetworkFildes != -1 || ReplayGameType != ReplayNone) {
+ if (NetworkFildes != (Socket)-1 || ReplayGameType != ReplayNone) {
mi->menu->Items[1].flags |= MenuButtonDisabled;
} else {
mi->menu->Items[1].flags &= ~MenuButtonDisabled;
}
// Disable load menu in multiplayer
- if (NetworkFildes != -1) {
+ if (NetworkFildes != (Socket)-1) {
mi->menu->Items[2].flags |= MenuButtonDisabled;
} else {
mi->menu->Items[2].flags &= ~MenuButtonDisabled;
@@ -2148,7 +2148,7 @@
}
// Not available in net games or replays
- if (NetworkFildes == -1 && ReplayGameType == ReplayNone) {
+ if (NetworkFildes == (Socket)-1 && ReplayGameType == ReplayNone) {
menu->Items[1].flags = MI_ENABLED;
} else {
menu->Items[1].flags = MI_DISABLED;
@@ -7130,7 +7130,7 @@
}
}
++n;
- mi->d.pulldown.options = (unsigned char **)malloc(n * sizeof(char *));
+ mi->d.pulldown.options = (unsigned char **)malloc(n * sizeof(unsigned char
*));
for (i = 0, n = 0; i < PlayerRaces.Count; ++i) {
if (PlayerRaces.Visible[i]) {
mi->d.pulldown.options[n++] = strdup(PlayerRaces.Display[i]);
Index: stratagus/src/ui/mouse.c
diff -u stratagus/src/ui/mouse.c:1.148 stratagus/src/ui/mouse.c:1.149
--- stratagus/src/ui/mouse.c:1.148 Thu Sep 18 13:56:04 2003
+++ stratagus/src/ui/mouse.c Mon Sep 29 22:53:03 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: mouse.c,v 1.148 2003/09/18 17:56:04 n0body Exp $
+// $Id: mouse.c,v 1.149 2003/09/30 02:53:03 jsalmon3 Exp $
//@{
@@ -386,7 +386,7 @@
//
// Handle buttons
//
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
if( TheUI.MenuButton.X!=-1 ) {
if( x>=TheUI.MenuButton.X
&& x<=TheUI.MenuButton.X+TheUI.MenuButton.Width
@@ -1622,7 +1622,7 @@
&& (ButtonUnderCursor==ButtonUnderMenu
|| ButtonUnderCursor==ButtonUnderNetworkMenu) ) {
// FIXME: Not if, in input mode.
- if( NetworkFildes==-1 ) {
+ if( NetworkFildes==(Socket)-1 ) {
GamePaused=1;
SetStatusLine("Game Paused");
}
Index: stratagus/src/video/sdl.c
diff -u stratagus/src/video/sdl.c:1.97 stratagus/src/video/sdl.c:1.98
--- stratagus/src/video/sdl.c:1.97 Sat Sep 27 14:05:41 2003
+++ stratagus/src/video/sdl.c Mon Sep 29 22:53:03 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sdl.c,v 1.97 2003/09/27 18:05:41 jsalmon3 Exp $
+// $Id: sdl.c,v 1.98 2003/09/30 02:53:03 jsalmon3 Exp $
//@{
@@ -622,8 +622,9 @@
struct timeval tv;
fd_set rfds;
fd_set wfds;
- int maxfd;
+ Socket maxfd;
int i;
+ int s;
SDL_Event event[1];
Uint32 ticks;
@@ -690,7 +691,7 @@
//
// Network
//
- if (NetworkFildes != -1) {
+ if (NetworkFildes != (Socket)-1) {
if (NetworkFildes > maxfd) {
maxfd = NetworkFildes;
}
@@ -710,7 +711,7 @@
#endif
#if 0
- maxfd = select(maxfd + 1, &rfds, &wfds, NULL,
+ s = select(maxfd + 1, &rfds, &wfds, NULL,
(i = SDL_PollEvent(event)) ? &tv : NULL);
#else
// QUICK HACK to fix the event/timer problem
@@ -720,7 +721,7 @@
// The event handling of SDL is wrong designed = polling only.
// There is hope on SDL 1.3 which will have this fixed.
- maxfd = select(maxfd + 1, &rfds, &wfds, NULL, &tv);
+ s = select(maxfd + 1, &rfds, &wfds, NULL, &tv);
i = SDL_PollEvent(event);
#endif
@@ -728,7 +729,7 @@
SdlDoEvent(callbacks, event);
}
- if (maxfd > 0) {
+ if (s > 0) {
#ifndef USE_SDLA
//
// Sound
@@ -742,7 +743,7 @@
//
// Network
//
- if (NetworkFildes != -1 && FD_ISSET(NetworkFildes, &rfds) ) {
+ if (NetworkFildes != (Socket)-1 && FD_ISSET(NetworkFildes, &rfds) )
{
callbacks->NetworkEvent();
}
}
@@ -750,7 +751,7 @@
//
// No more input and time for frame over: return
//
- if (!i && maxfd <= 0 && VideoInterrupts) {
+ if (!i && s <= 0 && VideoInterrupts) {
break;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src clone/clone.c clone/mainloop.c cl...,
Jimmy Salmon <=