New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating hidden window for messages #5

Merged
merged 9 commits into from May 7, 2016

clean up unused code

  • Loading branch information...
pawelsawicz committed May 3, 2016
commit a967bb6b0008f05122831e39fe607c46f39851e6
@@ -108,7 +108,7 @@ void cApplicationStartup::Startup()
InitializeSockets();
StartHGServer();
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); // get know what it does!
/*G_mmTimer = _StartTimer(TICKDELAY);
@@ -25,10 +25,6 @@ static HINSTANCE BCX_hInstance;
static int BCX_ScaleX;
static int BCX_ScaleY;
static char BCX_ClassName[2048];
HWND BCX_Listbox(char*,HWND,int,int,int,int,int,int=0,int=-1);
HWND BCX_Editbox(char*,HWND,int,int,int,int,int,int=0,int=-1);
HWND BCX_Button(char*,HWND,int,int,int,int,int,int=0,int=-1);
void ParseCommand(char*);
int ItemCount=0;
bool scrolling = true;
@@ -166,10 +162,6 @@ void OnPaint()
EndPaint(G_hWnd, &ps);
}
//=============================================================================
void OnKeyUp(WPARAM wParam, LPARAM lParam)
{
}
//=============================================================================
void OnAccept()
{
g_game->bAccept(G_pListenSock);
@@ -252,6 +244,7 @@ void Assertion(const char * assertion, const char * file, const uint32 line)
else if(strlen(cMsg) > MAXLOGLINESIZE) return;
if(PutOnFile == TRUE) PutLogFileList(cMsg, FileName);
}*/
void PutLogList(const char * cMsg)
{
@@ -262,20 +255,24 @@ void PutLogList(const char * cMsg)
SendMessage(List1,(UINT)LB_SETCURSEL,ItemCount,0);
ItemCount++;
}
void PutLogList(const string msg)
{
PutLogList(msg.c_str());
}
void LogError(const char * cMsg)
{
PutLogList("");
PutLogList(cMsg);
PutLogList("");
}
void LogError(const string msg)
{
LogError(msg.c_str());
}
//=============================================================================
BYTE bGetOffsetValue(char * cp, DWORD offset)
{
@@ -379,287 +376,3 @@ bool IsSame(char *c1, char *c2)
else return false;
}
//=============================================================================
HWND BCX_Listbox(char* Text,HWND hWnd,int id,int X,int Y,int W,int H,int Style,int Exstyle)
{
HWND A;
if (!Style)
{
Style = WS_VSCROLL | WS_VISIBLE | WS_CHILD | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_TABSTOP;
}
if (Exstyle == -1)
{
Exstyle=WS_EX_CLIENTEDGE;
}
A = CreateWindowEx(Exstyle,"Listbox",NULL,Style,
X*BCX_ScaleX, Y*BCX_ScaleY, W*BCX_ScaleX, H*BCX_ScaleY,
hWnd,(HMENU)id,BCX_hInstance,NULL);
SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObject
(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
return A;
}
HWND BCX_Editbox(char* Text,HWND hWnd,int id,int X,int Y,int W,int H,int Style,int Exstyle)
{
HWND A;
if (!Style)
{
Style = WS_VISIBLE | WS_CHILD | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_TABSTOP;
}
if (Exstyle == -1)
{
Exstyle=WS_EX_CLIENTEDGE;
}
A = CreateWindowEx(Exstyle,"EDIT",NULL,Style,
X*BCX_ScaleX, Y*BCX_ScaleY, W*BCX_ScaleX, H*BCX_ScaleY,
hWnd,(HMENU)id,BCX_hInstance,NULL);
SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObject
(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
return A;
}
HWND BCX_Button(char* Text,HWND hWnd,int id,int X,int Y,int W,int H,int Style,int Exstyle)
{
HWND A;
if (!Style)
{
Style = WS_CHILD | WS_VISIBLE | WS_BORDER;
}
A = CreateWindowEx(0,"Button",Text,Style,
X*BCX_ScaleX, Y*BCX_ScaleY, W*BCX_ScaleX, H*BCX_ScaleY,
hWnd,(HMENU)id,BCX_hInstance,NULL);
SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObject
(DEFAULT_GUI_FONT),(LPARAM)MAKELPARAM(FALSE,0));
return A;
}
void parseCommand(char* pMsg)
{
if (pMsg == NULL) return;
char seps[] = "= \t\n";
char * token, * token2;
class CStrTok * pStrTok;
char * cName[11];
char buff[100];
BOOL bFlag;
int i;
pStrTok = new class CStrTok(pMsg, seps);
token = pStrTok->pGet();
token2 = pStrTok->pGet();
bFlag = false;
/* if (memcmp(pMsg,"ascii ",5) == 0) {
//if (strlen(token) == 1) {
bFlag = TRUE;
char znak[1];
memcpy(znak,token,1);
wsprintf(buff,"AscII%d/%s.txt",znak[0],token);
PutLogList(buff);
}*/
if (memcmp(pMsg,"check ",6) == 0) {
if(!g_clientList)
{
PutLogList("No client list! Server is probably off.");
return;
}
if (token2 != NULL) {
ZeroMemory(cName, sizeof(cName));
memcpy(cName, token2,11);
}
if (cName != NULL) {
for (i = 1; i < MAXCLIENTS; i++)
if ((g_clientList[i] != NULL) && (memcmp(g_clientList[i]->m_cCharName, cName, 10) == 0)) {
ZeroMemory(buff, sizeof(buff));
if ((g_clientList[i] != NULL) && (memcmp(g_clientList[i]->m_cCharName, cName, 10) == 0)) {
wsprintf(buff, "%s: Str:%d Dex:%d Vit:%d Int:%d Mag:%d Chr:%d Map:%s - %i , %i Admin level:%i", g_clientList[i]->m_cCharName, g_clientList[i]->GetStr(), g_clientList[i]->GetDex(), g_clientList[i]->GetVit(), g_clientList[i]->GetInt(),g_clientList[i]->GetMag(), g_clientList[i]->m_iCharisma, g_clientList[i]->m_cMapName, g_clientList[i]->m_sX, g_clientList[i]->m_sY, g_clientList[i]->m_iAdminUserLevel);
PutLogList(buff);
}else{
wsprintf(buff,"Player %s is offline.", cName);
PutLogList(buff);
}
}
}
}
/*
if (memcmp(pMsg,"start apocalypse",16) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
g_game->GlobalStartApocalypseMode();
}
if (memcmp(pMsg,"end apocalypse",14) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
g_game->GlobalEndApocalypseMode();
}
*/
else if (memcmp(pMsg,"start heldenian",15) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
g_game->StartHeldenianMode();
}
else if (memcmp(pMsg,"end heldenian 1",15) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
g_game->HeldenianEndWarNow(g_game->m_iHeldenianType, ARESDEN);
}
else if (memcmp(pMsg,"end heldenian 2",15) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
g_game->HeldenianEndWarNow(g_game->m_iHeldenianType, ELVINE);
}
else if (memcmp(pMsg,"start crusade",13) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
g_game->GlobalStartCrusadeMode();
}else if (memcmp(pMsg,"end crusade",11) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
g_game->ManualEndCrusadeMode(0);
}else if (memcmp(pMsg,"benchmark",9) == 0) {
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
int ix = 60, iy = 60;
Point p;
p.x = p.y = 60;
CMap * map = g_game->m_pMapList[1];
DWORD time;
time = timeGetTime();
uint32 count = 0;
for(uint32 i=0; i < 100000000; i++)
{
count += map->bGetIsMoveAllowedTile(p);
}
char txt[50];
ZeroMemory(txt, sizeof(txt));
wsprintf(txt, "time: %u, %u", timeGetTime() - time, count);
PutLogList(txt);
}
else if (memcmp(pMsg,"broadcast ",10) == 0) {
if(!g_clientList)
{
PutLogList("No client list! Server is probably off.");
return;
}
if(!g_game)
{
PutLogList("Couldn't get the game server pointer! Server is probably off.");
return;
}
//tLogList(token2);
char ss[100];
ZeroMemory(ss,100);
memcpy(ss,pMsg,strlen(pMsg));
ss[0]=' ';
ss[1]=' ';
ss[2]=' ';
ss[3]=' ';
ss[4]=' ';
ss[5]=' ';
ss[6]=' ';
ss[7]=' ';
ss[8]=' ';
ss[9]=' ';
int i;
char*p=ss;
while(isspace(*p) && (*p))p++;
memmove(ss,p,strlen(p)+1);
wsprintf(ss,"%s",ss);
int do_ilu;
do_ilu=0;
// Send to clients on current HG
for (i = 1; i < MAXCLIENTS; i++) {
if (g_clientList[i] != NULL) {
g_game->ShowClientMsg(i,ss);
do_ilu++;
}
}
// Send to all other HGs through Login Server
if (strlen(ss) < 90) {
char * cp2;
WORD * wp;
char * pkt = new char[strlen(ss) + 20];
ZeroMemory(pkt, strlen(ss) + 20);
cp2 = (char *)pkt;
*cp2 = GSM_CHATMSG;
cp2++;
*cp2 = CHAT_GM;
cp2++;
//ip = (int *)cp2;
//*ip = NULL;
cp2 += 4;
strcpy(cp2, "Server");
cp2 += 10;
wp = (WORD *)cp2;
*wp = (WORD)strlen(ss);
cp2 += 2;
strcpy(cp2, ss);
cp2 += strlen(ss);
g_game->bStockMsgToGateServer(pkt, strlen(ss) + 18);
}
char buff[100];
wsprintf(buff,"(!) The Message '%s' was sent to all players ( %d )",ss,do_ilu);
PutLogList(buff);
}else if(memcmp(pMsg, "maplist", 7) == 0){
if(!g_mapList) return;
for (i = 0; i < MAXMAPS; i++)
if (g_mapList[i] != NULL) {
wsprintf(buff, "[%d] %s", g_mapList[i]->m_iTotalActiveObject, g_mapList[i]->m_cName);
PutLogList(buff);
}
}else if(memcmp(pMsg, "clientlist", 10) == 0){
if(!g_clientList) return;
for (i = 0; i < MAXCLIENTS; i++)
if (g_clientList[i] != NULL) {
wsprintf(buff, "Char:%s(%d) %s on %s (%s)", g_clientList[i]->m_cCharName,
g_clientList[i]->m_iLevel,
GetFactionName(g_clientList[i]->GetFaction()),
g_clientList[i]->m_cAccountName,
g_clientList[i]->m_cIPaddress);
PutLogList(buff);
}
}else{
wsprintf(buff,"(!!!) %s - unrecognized commad",pMsg);
PutLogList(buff);
}
}