This commit is contained in:
False.Genesis 2007-01-05 22:00:53 +00:00
parent fe91c8ebd6
commit d744135e02
6 changed files with 19 additions and 9 deletions

View File

@ -3,6 +3,11 @@
#define __DEFSCRIPT_H #define __DEFSCRIPT_H
#define MAXARGS 99 #define MAXARGS 99
#ifdef _DEBUG
# define _DEFSC_DEBUG(code) code;
#else
# define _DEFSC_DEBUG(code) /* code */
#endif
#include <map> #include <map>
#include "VarSet.h" #include "VarSet.h"

View File

@ -149,7 +149,9 @@ bool VarSet::ReadVarsFromFile(std::string fn)
vn=prefix+v; vn=prefix+v;
vv=line.substr(pos+1,line.length()-1); vv=line.substr(pos+1,line.length()-1);
Set(vn,vv); Set(vn,vv);
DEB(printf("DEBUG: Var import [%s] = %s\n",vn.c_str(),vv.c_str());); #ifdef _DEBUG
printf("DEBUG: Var import [%s] = %s\n",vn.c_str(),vv.c_str());
#endif
} }
// else invalid line, must have '=' // else invalid line, must have '='
} }

View File

@ -121,9 +121,10 @@ void PseuInstance::Run(void)
_rsession->SetHost(GetConf()->realmlist); _rsession->SetHost(GetConf()->realmlist);
_rsession->SetPort(GetConf()->realmport); _rsession->SetPort(GetConf()->realmport);
_rsession->SetInstance(this);
_rsession->Start(); _rsession->Start();
if(_rsession->IsValid()) if(_rsession->IsValid()) // TODO: need better check for IsValid(), it must check also if it could connect
{ {
_sh.Add(_rsession); _sh.Add(_rsession);
_rsession->SendLogonChallenge(); _rsession->SendLogonChallenge();
@ -143,7 +144,7 @@ void PseuInstance::Update()
if(_sh.GetCount()) if(_sh.GetCount())
_sh.Select(1,0); // update the realmsocket _sh.Select(1,0); // update the realmsocket
//else //else
// socket invalid // socket invalid?
_wsession->Update(); _wsession->Update();

View File

@ -104,12 +104,14 @@ void RealmSocket::SetInstance(PseuInstance *pi)
void RealmSocket::Start(void) void RealmSocket::Start(void)
{ {
if(this->_rhost.empty() || _rport==0 || !_valid || _instance==NULL) if(_rhost.empty() || _rport==0 || _instance==NULL)
return; return;
// is here any other socket code neded?
// _socket.Init() // _socket.Init()
// _socket.SetHost(_host); // _socket.SetHost(_host);
// _socket.SetPort(_port); // _socket.SetPort(_port);
Open(_rhost,_rport); Open(_rhost,_rport);
//... //...
_valid=true; _valid=true;

View File

@ -59,7 +59,7 @@ bool PlayerNameCache::SaveToFile(void){
len=(*i)->_name.length(); len=(*i)->_name.length();
fh.write( (char*)&len,sizeof(uint8) ); fh.write( (char*)&len,sizeof(uint8) );
fh.write( (char*)(*i)->_name.c_str(),len ); fh.write( (char*)(*i)->_name.c_str(),len );
DEB(printf( "PlayerNameCache << " I64FMT " -> %s\n", (*i)->_guid, (*i)->_name.c_str());); DEBUG(printf( "PlayerNameCache << " I64FMT " -> %s\n", (*i)->_guid, (*i)->_name.c_str()););
} }
fh.close(); fh.close();
printf("PlayerNameCache saved successfully.\n"); printf("PlayerNameCache saved successfully.\n");
@ -100,7 +100,7 @@ bool PlayerNameCache::ReadFromFile(void){
cacheItem->_name=nameptr; cacheItem->_name=nameptr;
AddInfo(cacheItem); AddInfo(cacheItem);
printf("\rPlayerNameCache [ %u / %u ] items loaded",i+1,size); printf("\rPlayerNameCache [ %u / %u ] items loaded",i+1,size);
DEB(printf( " >> " I64FMT " -> %s\n", cacheItem->_guid, nameptr);); DEBUG(printf( " >> " I64FMT " -> %s\n", cacheItem->_guid, nameptr););
} }
printf("\n"); printf("\n");
delete nameptr; delete nameptr;

View File

@ -3,13 +3,13 @@
#ifdef _DEBUG #ifdef _DEBUG
#define DEB(code) code; #define DEBUG(code) code;
#define DEBUG_APPENDIX " - DEBUG" #define DEBUG_APPENDIX " - DEBUG"
#define CODEDEB(code) fprintf(stderr,"[[ %s ]]\n",#code); code; #define CODEDEB(code) fprintf(stderr,"[[ %s ]]\n",#code); code;
#else #else
#define DEB(code) ; #define DEBUG(code) /* code */
#define DEBUG_APPENDIX #define DEBUG_APPENDIX
#define CODEDEB(code) code; #define CODEDEB(code) (code;)
#endif #endif
#define ASSERT( assertion ) { if( !(assertion) ) { fprintf( stderr, "\n%s:%i ASSERTION FAILED:\n %s\n", __FILE__, __LINE__, #assertion ); throw "Assertion Failed"; #define ASSERT( assertion ) { if( !(assertion) ) { fprintf( stderr, "\n%s:%i ASSERTION FAILED:\n %s\n", __FILE__, __LINE__, #assertion ); throw "Assertion Failed";