From a1998899cb566a39aa953ebc6597dcd6f5ee5fa3 Mon Sep 17 00:00:00 2001 From: zeromus Date: Fri, 28 Jul 2006 05:46:27 +0000 Subject: [PATCH] problems preventing sdl win32 from compiling of course none of these should matter but the sdl code is dodgy it could use refinining in the future to really be platform agnostic --- drivers/pc/main.cpp | 2 +- drivers/pc/sdl.cpp | 6 ++--- drivers/pc/unix-netplay.cpp | 49 +++++++++++++++++++++++++++++-------- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/pc/main.cpp b/drivers/pc/main.cpp index 15b13b11..0270aa46 100644 --- a/drivers/pc/main.cpp +++ b/drivers/pc/main.cpp @@ -156,7 +156,7 @@ static void CreateDirs(void) int x; #ifdef WIN32 - mkdir(DrBaseDirectory); + mkdir((char *)DrBaseDirectory); for(x=0;x<6;x++) { sprintf(tdir,"%s"PSS"%s",DrBaseDirectory,subs[x]); diff --git a/drivers/pc/sdl.cpp b/drivers/pc/sdl.cpp index 5fb26188..6a0fd860 100644 --- a/drivers/pc/sdl.cpp +++ b/drivers/pc/sdl.cpp @@ -232,10 +232,10 @@ uint8 *GetBaseDirectory(void) #ifdef WIN32 char *sa; - ret=malloc(MAX_PATH+1); - GetModuleFileName(NULL,ret,MAX_PATH+1); + ret=(uint8*)malloc(MAX_PATH+1); + GetModuleFileName(NULL,(char*)ret,MAX_PATH+1); - sa=strrchr(ret,'\\'); + sa=strrchr((char*)ret,'\\'); if(sa) *sa = 0; #else diff --git a/drivers/pc/unix-netplay.cpp b/drivers/pc/unix-netplay.cpp index d13228da..11e29342 100644 --- a/drivers/pc/unix-netplay.cpp +++ b/drivers/pc/unix-netplay.cpp @@ -19,24 +19,33 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +//todo - ensure that #ifdef WIN32 makes sense +//consider changing this to use sdl net stuff? + #include -#include -#include -#include -#include + #include -#include -#include -#include #include #include -#include +#include +#include #include #include #include "main.h" #include "dface.h" #include "unix-netplay.h" +#ifdef WIN32 +#include +#else +#include +#include +#include +#include +#include +#include +#endif + #include "../../md5.h" #ifndef socklen_t @@ -95,8 +104,10 @@ int FCEUD_NetworkConnect(void) int tcpopt = 1; #ifdef BEOS if(setsockopt(TSocket, SOL_SOCKET, TCP_NODELAY, &tcpopt, sizeof(int))) - #else - if(setsockopt(TSocket, SOL_TCP, TCP_NODELAY, &tcpopt, sizeof(int))) + #elif WIN32 + if(setsockopt(TSocket, SOL_TCP, TCP_NODELAY, (char*)&tcpopt, sizeof(int))) + #else + if(setsockopt(TSocket, SOL_TCP, TCP_NODELAY, &tcpopt, sizeof(int))) #endif puts("Nodelay fail"); } @@ -175,10 +186,18 @@ int FCEUD_NetworkConnect(void) if(netplaynick) memcpy(sendbuf + 4 + 16 + 16 + 64 + 1,netplaynick,strlen(netplaynick)); + #ifdef WIN32 + send(Socket, (char*)sendbuf, sblen, 0); + #else send(Socket, sendbuf, sblen, 0); + #endif free(sendbuf); + #ifdef WIN32 + recv(Socket, (char*)buf, 1, 0); + #else recv(Socket, buf, 1, MSG_WAITALL); + #endif netdivisor = buf[0]; } @@ -193,7 +212,9 @@ int FCEUD_NetworkConnect(void) int FCEUD_SendData(void *data, uint32 len) { int check; +#ifndef WIN32 if(!ioctl(fileno(stdin),FIONREAD,&check)) +#endif if(check) { char buf[1024]; @@ -203,7 +224,11 @@ int FCEUD_SendData(void *data, uint32 len) *f=0; FCEUI_NetplayText((uint8 *)buf); } + #ifdef WIN32 + send(Socket, (char*)data, len ,0); + #else send(Socket, data, len ,0); + #endif return(1); } @@ -230,7 +255,11 @@ int FCEUD_RecvData(void *data, uint32 len) if(FD_ISSET(Socket,&funfun)) { + #ifdef WIN32 + if(recv(Socket,(char*)data,len,0) == len) + #else if(recv(Socket,data,len,MSG_WAITALL) == len) + #endif { //unsigned long beefie;