CC test version
This commit is contained in:
@@ -15,6 +15,18 @@
|
|||||||
//along with this program; if not, write to the Free Software
|
//along with this program; if not, write to the Free Software
|
||||||
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
// Enable use of network loaded games with zsnes:// file names
|
||||||
|
#define CCBETA
|
||||||
|
|
||||||
|
// Enable debug of network loaded games
|
||||||
|
//#define CCDEBUG
|
||||||
|
|
||||||
|
#ifdef CCBETA
|
||||||
|
#include <windows.h>
|
||||||
|
#include <winsock.h>
|
||||||
|
#include <commctrl.h>
|
||||||
|
#include "resource.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -24,12 +36,65 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CCDEBUG
|
||||||
|
FILE * ZFILELog = NULL;
|
||||||
|
|
||||||
|
void ZLog_Message (char *Message, ...)
|
||||||
|
{
|
||||||
|
char Msg[400];
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap,Message);
|
||||||
|
vsprintf(Msg,Message,ap );
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
strcat(Msg,"\r\n\0");
|
||||||
|
fwrite(Msg,strlen(Msg),1,ZFILELog);
|
||||||
|
fflush(ZFILELog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ZStart_Log (void)
|
||||||
|
{
|
||||||
|
char LogFileName[255];
|
||||||
|
// [4/15/2001] char *p;
|
||||||
|
|
||||||
|
strcpy(LogFileName,"zfile.log\0");
|
||||||
|
|
||||||
|
ZFILELog = fopen(LogFileName,"wb");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZStop_Log(void)
|
||||||
|
{
|
||||||
|
if(ZFILELog)
|
||||||
|
{
|
||||||
|
fclose(ZFILELog);
|
||||||
|
ZFILELog=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define ZLog_Message()
|
||||||
|
#define ZStart_Log()
|
||||||
|
#define ZStop_Log()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define DWORD unsigned int
|
#define DWORD unsigned int
|
||||||
#define BYTE unsigned char
|
#define BYTE unsigned char
|
||||||
|
|
||||||
|
|
||||||
FILE *FILEHANDLE[16];
|
FILE *FILEHANDLE[16];
|
||||||
DWORD CurrentHandle=0;
|
DWORD CurrentHandle=0;
|
||||||
|
|
||||||
|
#ifdef CCBETA
|
||||||
|
int FILETYPE[16]; // 0 = normal file 1 = network file
|
||||||
|
int FILESIZE[16]; // 0 = normal file else network size
|
||||||
|
char * FILEDATA[16]; // 0 = normal file else network data
|
||||||
|
int FILECURPOS[16]; // network currrent position
|
||||||
|
#endif
|
||||||
|
|
||||||
//Indicate whether the file must be opened using
|
//Indicate whether the file must be opened using
|
||||||
//zlib or not (used for gzip support)
|
//zlib or not (used for gzip support)
|
||||||
BYTE TextFile;
|
BYTE TextFile;
|
||||||
@@ -90,8 +155,361 @@ BYTE * ZFileDelFName;
|
|||||||
// return current position
|
// return current position
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CCBETA
|
||||||
|
|
||||||
|
/* Additional code to handle remote roms */
|
||||||
|
|
||||||
|
SOCKET gameServerSocket; /* tcp socket for the game Server */
|
||||||
|
SOCKADDR_IN gameServerAddress; /* address of the game server */
|
||||||
|
|
||||||
|
int InitTCPFile()
|
||||||
|
{
|
||||||
|
char blah[255];
|
||||||
|
WORD versionneeded = MAKEWORD(2,2);
|
||||||
|
WSADATA wsadata;
|
||||||
|
|
||||||
|
/* Startup winsock */
|
||||||
|
WSAStartup(versionneeded, &wsadata);
|
||||||
|
|
||||||
|
/* Verify version number and exit on wrong version */
|
||||||
|
if (wsadata.wVersion != versionneeded)
|
||||||
|
{
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
gameServerSocket=INVALID_SOCKET;
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ConnectGameServer(char *servername, unsigned int port)
|
||||||
|
{
|
||||||
|
char blah[255];
|
||||||
|
int retval,i;
|
||||||
|
LPHOSTENT host1;
|
||||||
|
unsigned long addr1;
|
||||||
|
int yesip;
|
||||||
|
WSADATA wsadata;
|
||||||
|
int timeout=1000;
|
||||||
|
|
||||||
|
host1 = gethostbyname(servername);
|
||||||
|
if (host1 == NULL)
|
||||||
|
{
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
gameServerSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
|
if(gameServerSocket == INVALID_SOCKET)
|
||||||
|
{
|
||||||
|
return(-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize server address */
|
||||||
|
gameServerAddress.sin_family = AF_INET;
|
||||||
|
gameServerAddress.sin_addr = *( (LPIN_ADDR) *host1->h_addr_list );
|
||||||
|
gameServerAddress.sin_port = htons((unsigned short)port);
|
||||||
|
|
||||||
|
retval = connect( gameServerSocket,
|
||||||
|
(LPSOCKADDR)&gameServerAddress,
|
||||||
|
sizeof(struct sockaddr));
|
||||||
|
if (retval == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
sprintf(blah,"Could not connect to other side");
|
||||||
|
MessageBox(NULL,blah,
|
||||||
|
"Error",
|
||||||
|
MB_SYSTEMMODAL|MB_OK);
|
||||||
|
closesocket(gameServerSocket);
|
||||||
|
return(-3);
|
||||||
|
}
|
||||||
|
|
||||||
|
setsockopt(gameServerSocket,SOL_SOCKET,SO_RCVTIMEO,
|
||||||
|
&timeout,sizeof(timeout));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendCommand(char *dptr, int dsize)
|
||||||
|
{
|
||||||
|
int retval,i;
|
||||||
|
retval = send(gameServerSocket,dptr,dsize,0);
|
||||||
|
if (retval == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
closesocket(gameServerSocket);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
receiveData(char *dptr, int dsize)
|
||||||
|
{
|
||||||
|
int retval;
|
||||||
|
/* get data with the socket */
|
||||||
|
retval = recv(gameServerSocket,dptr,dsize,0);
|
||||||
|
if (retval == SOCKET_ERROR)
|
||||||
|
{
|
||||||
|
closesocket(gameServerSocket);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
return(retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int checkconnection=0;
|
||||||
|
|
||||||
|
extern char fname[512];
|
||||||
|
|
||||||
|
void CCExit(void)
|
||||||
|
{
|
||||||
|
char temp[512];
|
||||||
|
if(checkconnection)
|
||||||
|
{
|
||||||
|
ZLog_Message("Disconnecting from server");
|
||||||
|
checkconnection=0;
|
||||||
|
// sprintf(temp,"cl");
|
||||||
|
// sendCommand(temp,strlen(temp));
|
||||||
|
// receiveData(temp,512);
|
||||||
|
closesocket(gameServerSocket);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern char romloadskip;
|
||||||
|
extern unsigned int pressed;
|
||||||
|
|
||||||
|
// Function given by Jereth
|
||||||
|
LPTHREAD_START_ROUTINE MonitorThreadProc(SOCKET s)
|
||||||
|
{
|
||||||
|
unsigned char * keys;
|
||||||
|
|
||||||
|
unsigned int clockstart;
|
||||||
|
unsigned int clocknow;
|
||||||
|
char temp[512];
|
||||||
|
char error[255];
|
||||||
|
int destruct = 10;
|
||||||
|
char sec[] = " seconds";
|
||||||
|
fd_set socketTest;
|
||||||
|
struct timeval timeOut = {0,0};
|
||||||
|
FD_ZERO(&socketTest);
|
||||||
|
FD_SET(s,&socketTest);
|
||||||
|
ZLog_Message("Starting monitor thread");
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
if(checkconnection)
|
||||||
|
{
|
||||||
|
if(!strstr(&fname[1],"zsnes://"))
|
||||||
|
{
|
||||||
|
ZLog_Message("Disconnecting from server");
|
||||||
|
checkconnection=0;
|
||||||
|
// sprintf(temp,"cl");
|
||||||
|
// sendCommand(temp,strlen(temp));
|
||||||
|
// receiveData(temp,512);
|
||||||
|
closesocket(gameServerSocket);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
sprintf(temp,"hi");
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
if(!strstr(temp,"ok"))
|
||||||
|
{
|
||||||
|
HMODULE hModule = GetModuleHandle(NULL);
|
||||||
|
HWND hwndNCD;
|
||||||
|
if(destruct>0)
|
||||||
|
hwndNCD = CreateDialog(hModule, MAKEINTRESOURCE
|
||||||
|
(IDD_NO_CONNECT), NULL, NULL);
|
||||||
|
while(destruct > 0)
|
||||||
|
{
|
||||||
|
if (destruct == 10)
|
||||||
|
clockstart = timeGetTime();
|
||||||
|
|
||||||
|
if (destruct == 1)
|
||||||
|
{
|
||||||
|
sec[7] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wsprintf(error, "This message will self-destruct in %d%s%s", destruct, sec, ".");
|
||||||
|
SetDlgItemText(hwndNCD, IDC_DESTRUCT,error);
|
||||||
|
clocknow = timeGetTime();
|
||||||
|
while(clocknow < (clockstart+1000))
|
||||||
|
{
|
||||||
|
clocknow = timeGetTime();
|
||||||
|
}
|
||||||
|
clockstart+=1000;
|
||||||
|
destruct--;
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyWindow(hwndNCD);
|
||||||
|
|
||||||
|
keys = (unsigned char *)&pressed;
|
||||||
|
keys[1]=1;
|
||||||
|
romloadskip=1;
|
||||||
|
}
|
||||||
|
Sleep(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DWORD ThreadId;
|
||||||
|
HANDLE theMonitor;
|
||||||
|
|
||||||
|
|
||||||
|
OpenConnection(char *User, char *Password, char *FileName)
|
||||||
|
{
|
||||||
|
HWND hwndNCD;
|
||||||
|
char temp[513];
|
||||||
|
int cur=0;
|
||||||
|
HMODULE hModule = GetModuleHandle(NULL);
|
||||||
|
|
||||||
|
ZLog_Message("Need to open %s",FileName);
|
||||||
|
|
||||||
|
ZLog_Message("Starting winsock");
|
||||||
|
if(InitTCPFile()!=0)
|
||||||
|
{
|
||||||
|
// printf("Winsock version 2.2 is needed\n");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZLog_Message("Connection to server");
|
||||||
|
|
||||||
|
if(ConnectGameServer("www.consoleclassix.com",11001)<0)
|
||||||
|
{
|
||||||
|
// printf("Error connecting to the game server\n");
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZLog_Message("Sending user name");
|
||||||
|
|
||||||
|
sprintf(temp,"%s",User);
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
|
||||||
|
if(!strstr(temp,"ok")) return 0;
|
||||||
|
|
||||||
|
ZLog_Message("Sending password");
|
||||||
|
|
||||||
|
sprintf(temp,"%s",Password);
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
|
||||||
|
if(!strstr(temp,"ok"))
|
||||||
|
{
|
||||||
|
ZLog_Message("Sending user name");
|
||||||
|
|
||||||
|
sprintf(temp,"%s",User);
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
|
||||||
|
if(!strstr(temp,"ok")) return 0;
|
||||||
|
|
||||||
|
ZLog_Message("Sending password");
|
||||||
|
|
||||||
|
sprintf(temp,"%s",Password);
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
if(!strstr(temp,"ok")) return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZLog_Message("Sending IP");
|
||||||
|
|
||||||
|
sprintf(temp,"255.255.255.255");
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
|
||||||
|
ZLog_Message("Sending op");
|
||||||
|
|
||||||
|
sprintf(temp,"op");
|
||||||
|
sendCommand(temp,strlen(temp)+1);
|
||||||
|
receiveData(temp,512);
|
||||||
|
|
||||||
|
ZLog_Message("Sending file name: %s",FileName);
|
||||||
|
|
||||||
|
sprintf(temp,"%s",FileName);
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
|
||||||
|
ZLog_Message("Sending ok reply");
|
||||||
|
|
||||||
|
sprintf(temp,"ok");
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
receiveData(temp,512);
|
||||||
|
|
||||||
|
sscanf(temp,"%d",&FILESIZE[CurrentHandle]);
|
||||||
|
|
||||||
|
FILEDATA[CurrentHandle]=(char *) malloc(FILESIZE[CurrentHandle]);
|
||||||
|
FILECURPOS[CurrentHandle]=0;
|
||||||
|
sprintf(temp,"ok");
|
||||||
|
sendCommand(temp,strlen(temp));
|
||||||
|
|
||||||
|
ZLog_Message("Reading file");
|
||||||
|
|
||||||
|
hwndNCD = CreateDialog(hModule, MAKEINTRESOURCE
|
||||||
|
(IDD_LOADING), NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while(cur<FILESIZE[CurrentHandle])
|
||||||
|
{
|
||||||
|
cur+=receiveData(FILEDATA[CurrentHandle]+cur,4096);
|
||||||
|
ZLog_Message("Reading file at %d",cur);
|
||||||
|
wsprintf(temp, "%7d/%7d", cur, FILESIZE[CurrentHandle]);
|
||||||
|
SetDlgItemText(hwndNCD, IDC_PARTDONE,temp);
|
||||||
|
SendDlgItemMessage(hwndNCD, IDC_PROGRESS1, PBM_SETPOS, 100*cur/FILESIZE[CurrentHandle],
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
DestroyWindow(hwndNCD);
|
||||||
|
|
||||||
|
atexit(CCExit);
|
||||||
|
theMonitor = CreateThread((LPSECURITY_ATTRIBUTES)NULL,
|
||||||
|
(DWORD)0,
|
||||||
|
(LPTHREAD_START_ROUTINE)MonitorThreadProc,
|
||||||
|
(LPVOID)gameServerSocket,
|
||||||
|
(DWORD)0,
|
||||||
|
(LPDWORD)&ThreadId);
|
||||||
|
ZLog_Message("Created thread %X",theMonitor);
|
||||||
|
|
||||||
|
SetThreadPriority(theMonitor,THREAD_PRIORITY_LOWEST);
|
||||||
|
checkconnection=1;
|
||||||
|
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Add this later to disconnect...
|
||||||
|
DWORD ZFileSystemDeInit()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int UPDialogDone;
|
||||||
|
char user[512];
|
||||||
|
char pass[512];
|
||||||
|
|
||||||
|
LRESULT CALLBACK UPDialogMain(HWND hDlg, UINT message, WPARAM wParam,
|
||||||
|
LPARAM lParam)
|
||||||
|
{
|
||||||
|
switch(message)
|
||||||
|
{
|
||||||
|
case WM_INITDIALOG:
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
case WM_COMMAND:
|
||||||
|
if(LOWORD(wParam)==IDOK)
|
||||||
|
{
|
||||||
|
if(!GetDlgItemText(hDlg, IDC_EDITUSER, user, 512)) *user=0;
|
||||||
|
if(!GetDlgItemText(hDlg, IDC_EDITPASS, pass, 512)) *pass=0;
|
||||||
|
|
||||||
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
|
UPDialogDone=1;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif CCBETA
|
||||||
|
|
||||||
|
|
||||||
DWORD ZFileSystemInit()
|
DWORD ZFileSystemInit()
|
||||||
{
|
{
|
||||||
|
ZStart_Log();
|
||||||
#ifdef __GZIP__
|
#ifdef __GZIP__
|
||||||
TextFile = 0;
|
TextFile = 0;
|
||||||
#else
|
#else
|
||||||
@@ -103,6 +521,94 @@ DWORD ZFileSystemInit()
|
|||||||
|
|
||||||
DWORD ZOpenFile()
|
DWORD ZOpenFile()
|
||||||
{
|
{
|
||||||
|
#ifdef CCBETA
|
||||||
|
char site[512];
|
||||||
|
char rom[512];
|
||||||
|
int i;
|
||||||
|
char * startstr;
|
||||||
|
char * endstr;
|
||||||
|
ZLog_Message("ZOpenFile %d %s",CurrentHandle, ZOpenFileName);
|
||||||
|
|
||||||
|
if((startstr=strstr(ZOpenFileName,"zsnes://"))&&strstr(ZOpenFileName,"smc"))
|
||||||
|
{
|
||||||
|
FILETYPE[CurrentHandle]=1;
|
||||||
|
startstr+=8;
|
||||||
|
if(!strstr(startstr,"@"))
|
||||||
|
{
|
||||||
|
HMODULE hModule = GetModuleHandle(NULL);
|
||||||
|
HWND hwndNCD;
|
||||||
|
|
||||||
|
ZLog_Message("Creating user/pass window");
|
||||||
|
|
||||||
|
UPDialogDone=0;
|
||||||
|
hwndNCD = DialogBox(hModule, MAKEINTRESOURCE
|
||||||
|
(IDD_USERPASS), NULL, UPDialogMain);
|
||||||
|
|
||||||
|
while(!UPDialogDone)
|
||||||
|
{
|
||||||
|
Sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyWindow(hwndNCD);
|
||||||
|
|
||||||
|
ZLog_Message("User : %s Pass : %s",user,pass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if((endstr=strstr(startstr,":"))==NULL) return 0xFFFFFFFF;
|
||||||
|
if((endstr-startstr)>512) return 0xFFFFFFFF;
|
||||||
|
for(i=0;i<endstr-startstr;i++)
|
||||||
|
user[i]=startstr[i];
|
||||||
|
user[endstr-startstr]=0;
|
||||||
|
|
||||||
|
startstr=endstr+1;
|
||||||
|
if((endstr=strstr(startstr,"@"))==NULL) return 0xFFFFFFFF;
|
||||||
|
if((endstr-startstr)>512) return 0xFFFFFFFF;
|
||||||
|
for(i=0;i<endstr-startstr;i++)
|
||||||
|
pass[i]=startstr[i];
|
||||||
|
pass[endstr-startstr]=0;
|
||||||
|
ZLog_Message("User : %s Pass : %s",user,pass);
|
||||||
|
startstr=endstr+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((endstr=strstr(startstr,"/"))==NULL) return 0xFFFFFFFF;
|
||||||
|
if((endstr-startstr)>512) return 0xFFFFFFFF;
|
||||||
|
for(i=0;i<endstr-startstr;i++)
|
||||||
|
site[i]=startstr[i];
|
||||||
|
site[endstr-startstr]=0;
|
||||||
|
|
||||||
|
startstr=endstr+1;
|
||||||
|
endstr=startstr+strlen(startstr);
|
||||||
|
if((endstr-startstr)>512) return 0xFFFFFFFF;
|
||||||
|
for(i=0;i<endstr-startstr;i++)
|
||||||
|
rom[i]=startstr[i];
|
||||||
|
rom[endstr-startstr]=0;
|
||||||
|
|
||||||
|
ZLog_Message("Site : %s Rom : %s",site,rom);
|
||||||
|
|
||||||
|
if(!OpenConnection(user,pass,rom))
|
||||||
|
{
|
||||||
|
MessageBox(NULL,
|
||||||
|
"Couldn't connect to server. Please check your user information and verify your internet connection","Fatal Error",
|
||||||
|
MB_SYSTEMMODAL|MB_OK);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentHandle+=1;
|
||||||
|
return(CurrentHandle-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(startstr=strstr(ZOpenFileName,"zsnes://"))
|
||||||
|
{
|
||||||
|
ZOpenFileName=strstr(startstr+8,"/")+1;
|
||||||
|
}
|
||||||
|
ZLog_Message("Replaced file name with %s",ZOpenFileName);
|
||||||
|
|
||||||
|
FILETYPE[CurrentHandle]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
if(ZOpenMode==0)
|
if(ZOpenMode==0)
|
||||||
{
|
{
|
||||||
if (TextFile)
|
if (TextFile)
|
||||||
@@ -147,16 +653,41 @@ DWORD ZOpenFile()
|
|||||||
|
|
||||||
DWORD ZCloseFile()
|
DWORD ZCloseFile()
|
||||||
{
|
{
|
||||||
|
#ifdef CCBETA
|
||||||
|
ZLog_Message("ZCloseFile %d",ZCloseFileHandle);
|
||||||
|
|
||||||
|
if(FILETYPE[ZCloseFileHandle]==1)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
#endif
|
||||||
if (TextFile)
|
if (TextFile)
|
||||||
fclose(FILEHANDLE[ZCloseFileHandle]);
|
fclose(FILEHANDLE[ZCloseFileHandle]);
|
||||||
else
|
else
|
||||||
gzclose(FILEHANDLE[ZCloseFileHandle]);
|
gzclose(FILEHANDLE[ZCloseFileHandle]);
|
||||||
|
#ifdef CCBETA
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
CurrentHandle-=1;
|
CurrentHandle-=1;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileSeek()
|
DWORD ZFileSeek()
|
||||||
{
|
{
|
||||||
|
#ifdef CCBETA
|
||||||
|
ZLog_Message("ZFileSeek %d",ZFileSeekHandle);
|
||||||
|
|
||||||
|
if(FILETYPE[ZFileSeekHandle]==1)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
if (ZFileSeekMode==0)
|
if (ZFileSeekMode==0)
|
||||||
@@ -174,11 +705,36 @@ DWORD ZFileSeek()
|
|||||||
gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
|
gzseek(FILEHANDLE[ZFileSeekHandle], ZFileSeekPos, mode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#ifdef CCBETA
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return(0xFFFFFFFF);
|
return(0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileRead()
|
DWORD ZFileRead()
|
||||||
{
|
{
|
||||||
|
#ifdef CCBETA
|
||||||
|
ZLog_Message("ZFileRead %d len:%d curpos:%d",ZFileReadHandle,ZFileReadSize,FILECURPOS[ZFileReadHandle]);
|
||||||
|
if(FILETYPE[ZFileReadHandle]==1)
|
||||||
|
{
|
||||||
|
if(FILECURPOS[ZFileReadHandle]>=FILESIZE[ZFileReadHandle]) return 0;
|
||||||
|
if((FILECURPOS[ZFileReadHandle]+ZFileReadSize)>FILESIZE[ZFileReadHandle])
|
||||||
|
{
|
||||||
|
ZFileReadSize=FILESIZE[ZFileReadHandle]-FILECURPOS[ZFileReadHandle];
|
||||||
|
}
|
||||||
|
ZLog_Message("Copying len:%d",ZFileReadSize);
|
||||||
|
|
||||||
|
memcpy(ZFileReadBlock,FILEDATA[ZFileReadHandle]+FILECURPOS[ZFileReadHandle],
|
||||||
|
ZFileReadSize);
|
||||||
|
FILECURPOS[ZFileReadHandle]+=ZFileReadSize;
|
||||||
|
|
||||||
|
ZLog_Message("File read done");
|
||||||
|
|
||||||
|
return ZFileReadSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
if (TextFile)
|
if (TextFile)
|
||||||
return(fread(ZFileReadBlock,
|
return(fread(ZFileReadBlock,
|
||||||
1,
|
1,
|
||||||
@@ -188,11 +744,23 @@ DWORD ZFileRead()
|
|||||||
return(gzread(FILEHANDLE[ZFileReadHandle],
|
return(gzread(FILEHANDLE[ZFileReadHandle],
|
||||||
ZFileReadBlock,
|
ZFileReadBlock,
|
||||||
ZFileReadSize));
|
ZFileReadSize));
|
||||||
|
#ifdef CCBETA
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD ZFileWrite()
|
DWORD ZFileWrite()
|
||||||
{
|
{
|
||||||
|
#ifdef CCBETA
|
||||||
|
ZLog_Message("ZFileWrite %d",ZFileWriteHandle);
|
||||||
|
if(FILETYPE[ZFileWriteHandle]==1)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
int res=0;
|
int res=0;
|
||||||
if (TextFile)
|
if (TextFile)
|
||||||
res = fwrite(ZFileWriteBlock,
|
res = fwrite(ZFileWriteBlock,
|
||||||
@@ -206,18 +774,33 @@ DWORD ZFileWrite()
|
|||||||
|
|
||||||
if (res!=ZFileWriteSize)
|
if (res!=ZFileWriteSize)
|
||||||
return(0xFFFFFFFF);
|
return(0xFFFFFFFF);
|
||||||
|
#ifdef CCBETA
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD ZFileTell()
|
DWORD ZFileTell()
|
||||||
{
|
{
|
||||||
|
#ifdef CCBETA
|
||||||
|
ZLog_Message("ZFileTell %d",ZFileTellHandle);
|
||||||
|
|
||||||
|
if(FILETYPE[ZFileTellHandle]==1)
|
||||||
|
{
|
||||||
|
return(FILECURPOS[ZFileTellHandle]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
int res = 0;
|
int res = 0;
|
||||||
if (TextFile) {
|
if (TextFile) {
|
||||||
res = ftell(FILEHANDLE[ZFileTellHandle]);
|
res = ftell(FILEHANDLE[ZFileTellHandle]);
|
||||||
if (res == -1) fprintf(stderr, "Oups!! gzTell\n");
|
if (res == -1) fprintf(stderr, "Oups!! gzTell\n");
|
||||||
return(res);
|
return(res);
|
||||||
} else return gztell(FILEHANDLE[ZFileTellHandle]);
|
} else return gztell(FILEHANDLE[ZFileTellHandle]);
|
||||||
|
#ifdef CCBETA
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,143 @@
|
|||||||
|
//Microsoft Developer Studio generated resource script.
|
||||||
|
//
|
||||||
|
#include "resource.h"
|
||||||
|
|
||||||
|
#define APSTUDIO_READONLY_SYMBOLS
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 2 resource.
|
||||||
|
//
|
||||||
|
#include "afxres.h"
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#undef APSTUDIO_READONLY_SYMBOLS
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// English (U.S.) resources
|
||||||
|
|
||||||
|
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||||
|
#ifdef _WIN32
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
#pragma code_page(1252)
|
||||||
|
#endif //_WIN32
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Icon
|
||||||
|
//
|
||||||
|
|
||||||
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
|
// remains consistent on all systems.
|
||||||
IDR_MAINFRAME ICON DISCARDABLE "ZSNES.ICO"
|
IDR_MAINFRAME ICON DISCARDABLE "ZSNES.ICO"
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// TEXTINCLUDE
|
||||||
|
//
|
||||||
|
|
||||||
|
1 TEXTINCLUDE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
"resource.h\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
2 TEXTINCLUDE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
"#include ""afxres.h""\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
3 TEXTINCLUDE DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
"\r\n"
|
||||||
|
"\0"
|
||||||
|
END
|
||||||
|
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Dialog
|
||||||
|
//
|
||||||
|
|
||||||
|
IDD_NO_CONNECT DIALOG DISCARDABLE 0, 0, 197, 49
|
||||||
|
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
|
||||||
|
CAPTION "Connection Broken"
|
||||||
|
FONT 10, "MS Sans Serif"
|
||||||
|
BEGIN
|
||||||
|
LTEXT "You must maintain internet connection to use Console Classix.",
|
||||||
|
IDC_STATIC,7,9,183,8
|
||||||
|
CTEXT "",IDC_DESTRUCT,7,31,183,8
|
||||||
|
LTEXT "Please check your connection and try again.",IDC_STATIC,
|
||||||
|
32,20,132,8
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_LOADING DIALOG DISCARDABLE 0, 0, 190, 57
|
||||||
|
STYLE DS_SYSMODAL | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
|
||||||
|
FONT 10, "MS Sans Serif"
|
||||||
|
BEGIN
|
||||||
|
LTEXT "Loading the game from the server.",IDC_STATIC,41,3,107,
|
||||||
|
8
|
||||||
|
CTEXT "",IDC_PARTDONE,25,34,141,8
|
||||||
|
LTEXT "Please wait.",IDC_STATIC,76,12,38,8
|
||||||
|
CONTROL "Progress1",IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH |
|
||||||
|
WS_BORDER,28,21,135,10
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_USERPASS DIALOG DISCARDABLE 0, 0, 186, 95
|
||||||
|
STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_VISIBLE |
|
||||||
|
WS_CAPTION
|
||||||
|
CAPTION "User information"
|
||||||
|
FONT 8, "MS Sans Serif"
|
||||||
|
BEGIN
|
||||||
|
DEFPUSHBUTTON "OK",IDOK,68,74,50,14
|
||||||
|
LTEXT "User :",IDC_USER,48,27,20,8
|
||||||
|
LTEXT "Pass :",IDC_PASS,48,52,20,8
|
||||||
|
EDITTEXT IDC_EDITUSER,79,21,40,14,ES_AUTOHSCROLL
|
||||||
|
EDITTEXT IDC_EDITPASS,79,46,40,14,ES_PASSWORD | ES_AUTOHSCROLL
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// DESIGNINFO
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef APSTUDIO_INVOKED
|
||||||
|
GUIDELINES DESIGNINFO DISCARDABLE
|
||||||
|
BEGIN
|
||||||
|
IDD_LOADING, DIALOG
|
||||||
|
BEGIN
|
||||||
|
BOTTOMMARGIN, 55
|
||||||
|
END
|
||||||
|
|
||||||
|
IDD_USERPASS, DIALOG
|
||||||
|
BEGIN
|
||||||
|
LEFTMARGIN, 7
|
||||||
|
RIGHTMARGIN, 179
|
||||||
|
VERTGUIDE, 48
|
||||||
|
VERTGUIDE, 79
|
||||||
|
TOPMARGIN, 7
|
||||||
|
BOTTOMMARGIN, 88
|
||||||
|
HORZGUIDE, 35
|
||||||
|
HORZGUIDE, 60
|
||||||
|
END
|
||||||
|
END
|
||||||
|
#endif // APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
#endif // English (U.S.) resources
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef APSTUDIO_INVOKED
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Generated from the TEXTINCLUDE 3 resource.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
#endif // not APSTUDIO_INVOKED
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user