Exemple #1
0
	void showItemLocationMap()
	{
		PITEMLOCATIONMAPIT it( pItemLocationMap.begin() ), end( pItemLocationMap.end() );

		ConOut( "--------------------------------\n" );
		ConOut( "|      ITEM LOCATION MAP       |\n" );
		ConOut( "--------------------------------\n" );
		ConOut( "|   Key   | X  | Y  |  SERIAL  |\n" );
		ConOut( "--------------------------------\n" );

		UI32 	invalidCount	=  0;
		SI32 	x	  	=  0;
		SI32 	y		=  0;
		SERIAL	serial		= INVALID;
		for( ; it != end; ++it )
		{
			x = it->first >> 16;
			y = it->first & 0x0000FFFF;
			if( ISVALIDPI( it->second ) )
				serial = it->second->getSerial32();
			else
			{
				++invalidCount;
				serial = INVALID;
			}
			ConOut( "|%10i|%4i|%4i|%10i|\n", it->first, x, y, serial );
		}
		ConOut( "--------------------------------\n" );
		ConOut( "| entries in map : %10i  |\n", pItemLocationMap.size());
		ConOut( "| invalid entries: %10i  |\n", invalidCount );
		ConOut( "--------------------------------\n" );
	}
Exemple #2
0
bool GUI_ClientMenu::eventButtonClick(int id, PG_Widget* widget) {

	switch (id) {
	case 1:
		ConOut("");
		ConOutEx(MISC_FONT, "> Client menu sequence <");

		CommandExecuteOut("c_name %s", eClientName->GetText());
		CommandExecuteOut("c_desc %s", eClientDesc->GetText());

		if (cDelTmps->GetPressed()) CommandExecuteOut("c_deltmps 1");	else CommandExecuteOut("c_deltmps 0");
		if (cDRqs->GetPressed()) CommandExecuteOut("c_downloading 1"); else CommandExecuteOut("c_downloading 0");
		if (cURqs->GetPressed()) CommandExecuteOut("c_uploading 1"); else CommandExecuteOut("c_uploading 0");

		ConOutEx(MISC_FONT, "> end of sequence <");
		ConOut("");

		GUI_Return();
		break;

	case 2:
		Return();
		break;
	}

	return true;
}
Exemple #3
0
///////////////////////////////////////////////////////////////////
// Function name     : racCheckConn 
// Description       : checks periodically for new connections on rac socket
// Return type       : void 
// Author            : Xanathar 
// Changes           : none yet
void RemoteAdmin::CheckConn ()
{
	int s;
	socklen_t len;
	
	if ((rac_port==0) || (racnow>=MAXRACLIENT)) return;

	FD_ZERO(&conn);
	FD_SET(racSocket, &conn);
	nfds=racSocket+1;

	s=select(nfds, &conn, NULL, NULL, &nettimeout);	

	if (s<=0) return;
		
	ConOut("Connecting sockets...");
	len=sizeof (struct sockaddr_in);
	sockets[racnow] = accept(racSocket, (struct sockaddr *)&rac_sockets_addr, &len); 

	if ((sockets[racnow]<0)) {
		ConOut("[FAIL]\n");
		return;
	}
	
	if (Network->CheckForBlockedIP(client_addr))
	{
		ConOut("[BLOCKED!] IP Address: %s\n", inet_ntoa(rac_sockets_addr.sin_addr));
		closesocket(sockets[racnow]);
		return;
	}



	ConOut("[ OK ]\n");

	status[racnow]=RACST_CHECK_USR;
	inputptrs[racnow] = 0;

	// disable local echo for client
	Printf(racnow, "%c%c%c", IAC, WILL, ECHO);

	Printf(racnow, "%s %s.%s [%s]\r\n", PRODUCT, VERNUMB, HOTFIX, OS);
	Printf(racnow, "Remote Administration Console\r\n");
	Printf(racnow, "Program by Xanathar and Ummon\r\n");
	Printf(racnow, "http://nox-wizard.sunsite.dk\r\n");
	Printf(racnow, "\r\n");
	Printf(racnow, "INFO: character typed for login and password\r\n");
	Printf(racnow, "are not echoed, this is not a bug.\r\n");
/*	Printf(racnow, "%.4f Native Rate, %.4f AMX Rate\r\n\r\n", g_fNatRate, g_fAmxRate);
*/

	Printf(racnow, "\r\nLogin : ");
	racnow++;

}
/*!
\brief Reload all account
*/
void cAccounts::LoadAccounts( void )
{
	int b,c,ac;
	unsigned int account;
	char accnumb[264];
	char acc[264];
	char *t;
	lastusedacctnum = 0;
    char script1[1024];
    char script2[1024];

	FILE *F = fopen("config/accounts.adm", "rt");
	if (F==NULL) {
	#ifndef WIN32
		ConOut("************\nCan't load accounts. Can't continue.\n***********");
		ConOut("\nPress <return> to exit.");
		char str[80];
		fgets(str, 70, stdin);
	#else
		MessageBox(NULL, "Can't load accounts. Can't continue.", "Fatal Error - NoX-Wizard", MB_ICONHAND);
	#endif
		exit(1);
	}

	acctlist.clear();
	while (!feof(F))
	{
		readSplitted(F, script1, script2);
		if (feof(F)) break;
		if (!(strcmp(script1, "SECTION")))
		{
			c = strlen(script2);
			for (b=0; b<9; b++) acc[b]=script2[b];
			for (b=8; b<c; b++) accnumb[b-8]=script2[b];
			accnumb[b-8]=0; acc[8]=0;
			ac = strtol(accnumb, &t, 10);
			if (strlen(t)!=0) ac=-1;

			if (strcmp(acc,"ACCOUNT ") || ac < 0 )
			{
				ConOut("Error loading accounts, skipping invalid account entry!\n");

			} else {
			   account=ac;
			   LoadAccount(account, F);
			   if (account > lastusedacctnum)
				   lastusedacctnum = account;
			}
		}
	}
	fclose(F);
}
Exemple #5
0
///////////////////////////////////////////////////////////////////
// Function name     : racInit
// Description       : Initializes remote adm. console socket(s)
// Return type       : void 
// Author            : Xanathar 
// Changes           : none yet
void RemoteAdmin::Init()
{
	int bcode;
	ConOut( TRANSLATE("Initializing remote administration server..."));
	
	rac_port = ServerScp::g_nRacTCPPort;
	
	if (rac_port==0) 
	{
		ConOut("[DISABLED]\n");
		return;
	}
		
	racSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
	if (racSocket < 0 )
	{
		ConOut("[FAIL]\nERROR: Unable to create RAC socket\n");
		return;
	}


	raclen_connection_addr=sizeof (struct sockaddr_in);
	racconnection.sin_family=AF_INET;
	racconnection.sin_addr.s_addr=INADDR_ANY;	
	racconnection.sin_port=(((rac_port%256)<<8))+(rac_port>>8); //Port

	bcode = bind(racSocket, (struct sockaddr *)&racconnection, raclen_connection_addr);

	if (bcode!=0)
	{
		#ifndef __unix__
			bcode = WSAGetLastError ();
		#endif
		ConOut("[FAIL]\nERROR: Unable to bind RAC socket - Error code: %i\n",bcode);
		return;
	}
    
	bcode = listen(racSocket, MAXRACLIENT);

	if (bcode!=0)
	{
		ConOut("[FAIL]\nERROR: Unable to set RAC socket in listen mode  - Error code: %i\n",bcode);
		return;
	}

	unsigned long nonzero = 1;

	#if defined(__unix__)
		#ifndef __BEOS__
		ioctl(racSocket,FIONBIO,&nonzero) ;
		#endif
	#else
		ioctlsocket(racSocket,FIONBIO,&nonzero) ;
	#endif

	ConOut("[ OK ]\n");

}
void loadcontainers()
{

	cScpIterator*	iter = NULL;
	std::string	script1,
			script2;
	SI32 		gump = INVALID;
	BasicPosition	uprleft = {INVALID,INVALID};
	BasicPosition	dwnrght = {INVALID,INVALID};
	UI32VECTOR	*vet = new UI32VECTOR;

	int cont=0;

	int loopexit=0;
	do
	{
		safedelete(iter);
		iter = Scripts::Containers->getNewIterator("SECTION CONTAINER %i", cont++);
		if( iter==NULL ) continue;

		gump = INVALID;
		uprleft.x = INVALID;
		uprleft.y = INVALID;
		dwnrght.x = INVALID;
		dwnrght.y = INVALID;
		vet->clear();

		do
		{

			iter->parseLine(script1, script2);
			if ( script1[0]!='}' && script1[0]!='{' )
			{
				if	( "ID" == script1 )
					vet->push_back( str2num( script2 ) );
				else if ( "GUMP" == script1 )
					gump = str2num( script2 );
				else if ( "X1" == script1 )
					uprleft.x= str2num( script2 );
				else if ( "Y1" == script1 )
					uprleft.y= str2num( script2 );
				else if ( "X2" == script1 )
					dwnrght.x= str2num( script2 );
				else if ( "Y2" == script1 )
					dwnrght.y= str2num( script2 );
				else
					WarnOut("[ERROR] wrong line ( %s ) parsed on containers.xss", script1.c_str() );
			}
		}
		while ( script1[0] !='}' && ++loopexit < MAXLOOPS );

		if( (gump!=INVALID) && (uprleft.x!=INVALID) && (dwnrght.x!=INVALID) && (uprleft.y!=INVALID) && (dwnrght.y!=INVALID) )
		{
			cont_gump_st dummy;

			dummy.downright = dwnrght;
			dummy.upperleft = uprleft;
			dummy.gump	= gump;

			contInfoGump[gump] = dummy;

			CONTINFOGUMPMAP::iterator iter( contInfoGump.find(gump) );
			if( iter != contInfoGump.end() )
			{
				UI32VECTOR::iterator ids( vet->begin() ), end( vet->end() );
				for(; ids != end; ++ids )
					contInfo[(*ids)] = iter;
			}
			else
				ConOut("[ERROR] on parse of containers.xss" );
		}
		else
			ConOut("[ERROR] on parse of containers.xss" );
	}
	while ( script1 != "EOF" && ++loopexit < MAXLOOPS );

	safedelete(iter);

//	ConOut("\n");
//	for(CONTINFOMAP::iterator debug=contInfo.begin(); debug!=contInfo.end(); debug++ )
//		ConOut( "id %i ha gump %i \n ", debug->first, (debug->second)->second.gump);



}
void cMakeMenu::loadFromScript( P_CHAR pc )
{
	VALIDATEPC(pc);

	NXWCLIENT ps = pc->getClient();
	if( ps==NULL ) return;

    cScpIterator* iter = Scripts::Create->getNewIterator("SECTION MAKEMENU %i", section);
    if (iter==NULL) return;

	std::vector<std::string> names; //name
	std::vector<std::string> models; //models
    
	this->mat[0].number = ( mat[0].id!=0 )? pc->CountItems( mat[0].id, mat[0].color ) : 0;
	this->mat[1].number = ( mat[1].id!=0 )? pc->CountItems( mat[1].id, mat[1].color ) : 0;

	//da passare a checkReq PDPD
	

	cMakeItem* imk = NULL;
    pc->making=skill;

	oldmenu->style=MENUTYPE_ICONLIST;

/* makemenu menu
SECTION MAKEMENU 1
{
    Blacksmithing
    1416 Armor
    RESOURCE 10
    SKILL 500
    MAKEMENU 3
    13BA Weapons
    RESOURCE 3
    SKILL 100
    MAKEMENU 4
    1BC3 Shields
    RESOURCE 8
    SKILL 250
    MAKEMENU 2
    09ed Misc
    RESOURCE 6
    SKILL 150
    MAKEMENU 105
}
*/
/* makemenu item
SECTION MAKEMENU 2002
{
    Golden Ring Mail
    13F2 Gloves
    RESOURCE 10
    SKILL 338
    ADDITEM $item_golden_ringmail_gloves
    13EF Sleeves
    RESOURCE 14
    SKILL 385
    ADDITEM $item_golden_ringmail_sleeves
    13F1 Leggings
    RESOURCE 16
    SKILL 408
    ADDITEM $item_golden_ringmail_leggings
    13ED Tunic
    RESOURCE 18
    SKILL 432
    ADDITEM $item_golden_ringmail_tunic
}
*/

enum MakeParamType {
MAKE_NEED_NAME = 0, //Blacksmithing
MAKE_NEED_INFO, //1416 Armor
MAKE_NEED_RESOURCE, //RESOURCE 10
MAKE_NEED_SKILL, //SKILL 500
MAKE_NEED_MENUORITEM, //MAKEMENU 3  or ADDITEM $item_golden_ringmail_tunic
};

	MakeParamType type = MAKE_NEED_NAME;
	bool error=false;
	bool canSee = true;
	int item = INVALID;

    int loopexit=0;
    do
    {
		std::string lha;
		std::string rha;
        
	    iter->parseLine(lha, rha);

		if( lha[0]=='{' )
			continue;

		if( lha[0]=='}' )
			break;

		switch( type ) {

			case MAKE_NEED_NAME: //Blacksmithing
				string2wstring( lha, oldmenu->title );
				type = MAKE_NEED_INFO;
				break;

			case MAKE_NEED_INFO: { //1416 Armor
				item++;
				names.push_back( rha );
				models.push_back( lha );
				type = MAKE_NEED_RESOURCE;
				break;
			}
			case MAKE_NEED_RESOURCE: //RESOURCE 10
		        if( lha!="RESOURCE" ) {
					if ( item > INVALID ) //Luxor
						LogWarning("create.xss, MAKEMENU %i: Expected 'RESOURCE <num>' after '%s'!", section, names[item].c_str() );
					error=true;
				}
				else {
					int needs = str2num(rha);

					imk = new cMakeItem();
					
					imk->skillToCheck=this->skill;
					imk->reqitems[0].id=mat[0].id;
					imk->reqitems[0].color=mat[0].color;
					imk->reqitems[0].number=needs;
					imk->reqitems[1].id=mat[1].id;
					imk->reqitems[1].color=mat[1].color;
					imk->reqitems[1].number=needs;

					type=MAKE_NEED_SKILL;
				}
				break;
			case MAKE_NEED_SKILL:  //SKILL 500
				if( lha!="SKILL" )
				{
					LogWarning("create.xss, MAKEMENU %i: Expected 'SKILL <num>' after RESOURCE !", section );
					error=true;
		        }
				else {

					imk->minskill=str2num(rha);
				    imk->maxskill=imk->minskill*SrvParms->skilllevel; // by Magius(CHE)
					if( imk->maxskill<200 )
						imk->maxskill=200;

					if( !imk->checkReq( pc, true, &this->mat[0] ) )
					{
						safedelete( imk );
						item--;
						names.pop_back();
						models.pop_back();
						canSee = false;
					}
					else {
						makeItems.push_back( imk );
						
						std::wstring w;
						char b[TEMP_STR_SIZE];
						if( mat[0].id!=0 ) {
							sprintf( b, "%s %s - [%d/%d.%d]", models[item].c_str(), names[item].c_str(), imk->reqitems[0].number, imk->minskill/10, imk->minskill%10 );
						}
						else {
							sprintf( b, "%s %s", models[item].c_str(), names[item].c_str() );
						}
						string2wstring( std::string( b ), w );
						oldmenu->addMenuItem( 0, item, w );
						type=MAKE_NEED_MENUORITEM;
						canSee = true;
					}
					type=MAKE_NEED_MENUORITEM;
				}
				break;
			case MAKE_NEED_MENUORITEM: //MAKEMENU 3  or ADDITEM $item_golden_ringmail_tunic
				if( ( lha=="MAKEMENU" ) || ( lha=="ADDITEM" ) ) {
					if( canSee )
						imk->command = new cScriptCommand( lha, rha );
					type = MAKE_NEED_INFO;
				}
				else {
					LogWarning("create.xss, MAKEMENU %i: Expected'MAKEMENU or ADDITEM after 'SKILL %i'!", section, imk->minskill );
					error=true;
				}
				break;
		}
	}
	while( !error  && (++loopexit < MAXLOOPS) );


    if( item<=0 ) {
        ps->sysmsg( TRANSLATE("You aren't skilled enough to make anything with what you have.") );
    }

	safedelete(iter);
	if( error ) {
		ConOut( "[ERROR] on cration of makemenu %d\n", section );
        return;
	}

}
	/*!
	\brief Loats talk.scp and parsers it
	\author Elcabesa, Xanathar
	*/
	void init_translation()
	{   
		char buffer[1024];
		int i,j,ln,lnp,line=0;
		char *ptr;
		std::string mystr;
		std::string mystr2;
		bool bOk, bError, bWereErrors = false;

		ConOut("Initializing translation...");
		FILE *F;

		F = fopen("talk.scp", "rt");

		if (F==NULL) {
			ConOut("[FAIL]\n"); 
			return;
		}

		while (!feof(F))
		{
			fgets(buffer, 1000, F);
				line++;
			ln = strlen(buffer);
			if (ln<1) continue;
			if (buffer[0]=='/') continue;
			buffer[ln-1] = '\0';
				if (ln>=2) {
					if ((buffer[ln-2]=='\n')||(buffer[ln-2]=='\r')) buffer[ln-2]='\0';
				}
			ptr = NULL;

			for (i=0; i<ln; i++) 
			{ 
			if (buffer[i] == '$') {
				buffer[i] = '\0';
				ptr = buffer+i+1;
				break;
			}
			}

			if (ptr == NULL) continue;

				//Here : check if %'s are correct for printf-like strings
				ln = strlen(buffer);
				lnp = strlen(ptr);
				j = 0;
				bOk = false;
				bError = false;
				for(i=0; i<(ln+lnp+1);i++)
				{

					if(	( (buffer[i] < 'a') || (buffer[i] > 'z') ) &&
						( (buffer[i] < 'A') || (buffer[i] > 'Z') ) &&
						( (buffer[i] < '0') || (buffer[i] > '9') ) &&
						(buffer[i]!='!') &&
						(buffer[i]!='"') && (buffer[i]!='#') && (buffer[i]!='$') &&
						(buffer[i]!='%') && (buffer[i]!='&') && (buffer[i]!='\'') &&
						(buffer[i]!='(') && (buffer[i]!=')') && (buffer[i]!='*') &&
						(buffer[i]!='+') && (buffer[i]!=',') && (buffer[i]!='.') && 
						(buffer[i]!='-') && (buffer[i]!='/') && (buffer[i]!=':') && 
						(buffer[i]!=';') && (buffer[i]!='>') && (buffer[i]!='<') &&
						(buffer[i]!='=') && (buffer[i]!='?') && (buffer[i]!='@') && 
						(buffer[i]!='[') && (buffer[i]!=']') && (buffer[i]!='\\') && 
						(buffer[i]!='_') && (buffer[i]!=' ') && (buffer[i]!='\n') &&
						(buffer[i]!='\0')&& (buffer[i]!='`') && (buffer[i]!='\t')// Horizontal tab
						)
					{
						if (!bWereErrors) 
						{
							ConOut("[FAIL]\n");
							bWereErrors = true;
						}
						ConOut("Incorrect translation at line %i.You have used a bad char like %c.Translation will be ignored.\n", line, buffer[i]);
						bError = true;
					}
				}
				for(i=0; i<ln; i++) {
					bOk = false;

					if ((buffer[i]=='%')&&(buffer[i+1]=='%')) { i++; continue; }

					if (buffer[i]=='%') {
						for(; j<lnp; j++) {
							if ((ptr[j]=='%')&&(ptr[j+1]=='%')) { j++; continue; }
							if (ptr[j]=='%') {
								bOk = (ptr[j+1]==buffer[i+1]);
								j++; //otherwise next loop we'll start here :|
								break;
							} //ptr j = %
						} // for j
						if ((j>=lnp)||(!bOk)) {
							if (!bWereErrors) {
								ConOut("[FAIL]\n");
								bWereErrors = true;
							}
							ConOut("Incorrect translation of \"%s\" in \"%s\" at line %i.Translation will be ignored.\n", buffer, ptr, line);
							bError = true;
							break;
						} // if not ok 
					} // if buffer[i] == %
				} // for i

				if (!bError) {
					mystr.erase();
					mystr=buffer;
					mystr2.erase();
					mystr2=ptr;
					s_mapTranslation.insert(make_pair(mystr, mystr2));
				}
		} // while not eof

		fclose(F);

		if (!bWereErrors) ConOut("[ OK ]\n");
		#ifdef _WINDOWS
			if (bWereErrors) MessageBox(NULL, "Error(s) found in talk.scp. Please check them.", "Translation errors", MB_ICONWARNING);
		#endif
	}
Exemple #9
0
/*!
\brief initializes to nulls the hash queues for amx events
\author Xanathar
*/
void initAmxEvents(void)
{ 
	ConOut("Initializing event callback hash queue...");
	for (int i=0; i<256; i++) HashQueue[i] = NULL; 
	ConOut("[DONE]");
}
Exemple #10
0
void drop_item(NXWCLIENT ps) // Item is dropped
{

	if (ps == NULL) return;

	NXWSOCKET  s=ps->toInt();
//	CHARACTER cc=ps->currCharIdx();

	PKGx08 pkgbuf, *pp=&pkgbuf;

	pp->Iserial=LongFromCharPtr(buffer[s]+1);
	pp->TxLoc=ShortFromCharPtr(buffer[s]+5);
	pp->TyLoc=ShortFromCharPtr(buffer[s]+7);
	pp->TzLoc=buffer[s][9];
	pp->Tserial=LongFromCharPtr(buffer[s]+10);

    //#define debug_dragg

	if (clientDimension[s]==3)
	{
	  // UO:3D clients send SOMETIMES two dragg packets for a single dragg action.
	  // sometimes we HAVE to swallow it, sometimes it has to be interpreted
	  // if UO:3D specific item loss problems are reported, this is probably the code to blame :)
	  // LB

	  P_ITEM pi = pointers::findItemBySerial(pp->Iserial);

	  #ifdef debug_dragg
	    if (ISVALIDPI(pi)) { sprintf(temp, "%04x %02x %02x %01x %04x i-name: %s EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, pi->name, clientInfo[s]->evilDrag); ConOut(temp); }
		else { sprintf(temp, "blocked: %04x %02x %02x %01x %04x i-name: invalid item EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, clientInfo[s]->evilDrag); ConOut(temp); }
	  #endif

	  if  ( (pp->TxLoc==-1) && (pp->TyLoc==-1) && (pp->Tserial==0)  && (clientInfo[s]->evilDrag) )
	  {
		  clientInfo[s]->evilDrag=false;
          #ifdef debug_dragg
		    ConOut("Swallow only\n");
          #endif
		  return;
	  }	 // swallow! note: previous evildrag !

	  else if ( (pp->TxLoc==-1) && (pp->TyLoc==-1) && (pp->Tserial==0)  && (!clientInfo[s]->evilDrag) )
	  {
          #ifdef debug_dragg
		    ConOut("Bounce & Swallow\n");
          #endif

		  item_bounce6(ps, pi);
		  return;
	  }
	  else if ( ( (pp->TxLoc!=-1) && (pp->TyLoc!=-1) && ( pp->Tserial!=-1)) || ( (pp->Iserial>=0x40000000) && (pp->Tserial>=0x40000000) ) )
		  clientInfo[s]->evilDrag=true; // calc new evildrag value
	  else clientInfo[s]->evilDrag=false;
	}

	#ifdef debug_dragg
	  else
	  {
		P_ITEM pi = pointers::findItemBySerial(pp->Iserial);

	     if (ISVALIDPI(pi)) { sprintf(temp, "blocked: %04x %02x %02x %01x %04x i-name: %s EVILDRAG-old: %i\n",pp->Iserial, pp->TxLoc, pp->TyLoc, pp->TzLoc, pp->Tserial, pi->name, clientInfo[s]->evilDrag); ConOut(temp); }
	  }
	#endif


//	if ( (buffer[s][10]>=0x40) && (buffer[s][10]!=0xff) )
	if ( isItemSerial(pp->Tserial) && (pp->Tserial != INVALID)  ) // Invalid target => invalid container => put inWorld !!!
		pack_item(ps,pp);
	else
		dump_item(ps,pp);
}
Exemple #11
0
///////////////////////////////////////////////////////////////////
// Function name     : racProcessInput
// Description       : processes input from socket s
// Return type       : void 
// Author            : Xanathar 
// Argument          : int s -> socket to process input
// Changes           : rewritten by Anthalir
void RemoteAdmin::ProcessInput(int s)
{
	char inp2[1024]= {'\0'};
	char *inp= inp2;
	UI32 i;


	if (rac_port==0) return;

	if( !strncmp(&inputbufs[s][0], "!!", 2) )
	{
		strcpy(inp2, oldinp[s]);
	}
	else 
	{
		int j=0;
		for (int i=0; i<inputptrs[s]; i++)
		{
			if (inputbufs[s][i]!='\b')		// \b = bell
				inp2[j++] = inputbufs[s][i];
		}

		strncpy(oldinp[s], inp2, sizeof(oldinp[s])-1);
	}

	// remove spaces and tabulations at string start
	while( isspace(inp[0]) )
		inp++;

	if (status[s]==RACST_STDIN)
	{
		for (i=0; i< strlen(inp); i++)
		{
			if ((inp[i]>='a')&&(inp[i]<='z')) 
				inp[i] -= 'a'-'A';

			if (inp[i]==' ') break;
		}
	}
		
	inputptrs[s] = 0;

	if (status[s]==RACST_CHECK_USR)
	{
		strcpy(loginname[s], inp);
		Printf(s, "password : "******"\r\nAccess Denied.\r\nPress any key to get disconnected...");
			ConOut("Access Denied on Remote Console for user '%s' with pass '%s'\n", loginname[s], inp);
			status[s]=RACST_ACCESS_DENIED;
			return;
		} else {
			status[s]=RACST_STDIN;
			Printf(s,"\r\n\r\n");
			Printf(s,"------------------------------------------------------------------------\r\n");
			Printf(s,"Welcome to the administration console\r\n");
			Printf(s,"\r\nType HELP to receive help on commands.\r\n");
			Printf(s,"If you are not authorized to access this system\r\n");
			Printf(s,"please exit immediately by typing the EXIT command\r\n");
			Printf(s,"or by closing your client. Any other unauthorized\r\n");
			Printf(s,"action can be persecuted by law.\r\n");
			Printf(s,"\r\n");

			// re-enable local echo for client
			Printf(s, "%c%c%c", IAC, DO, ECHO);
			Printf(s, "%c%c%c", IAC, WONT, ECHO);

			ConOut("Authorised acces on Remote Console by user %s\n", loginname[s]);
			return;
		}
	}

	if (status[s]!=RACST_STDIN) return;

	if (!strcmp(inp,"PDUMP")) 
	{
		Printf(s, "Performace Dump:\r\n");

		Printf(s, "Network code: %fmsec [%i]", (float)((float)networkTime/(float)networkTimeCount), networkTimeCount);
		Printf(s,"Timer code: %fmsec [%i]" , (float)((float)timerTime/(float)timerTimeCount) , timerTimeCount);
		Printf(s,"Auto code: %fmsec [%i]" , (float)((float)autoTime/(float)autoTimeCount) , autoTimeCount);
		Printf(s,"Loop Time: %fmsec [%i]" , (float)((float)loopTime/(float)loopTimeCount) , loopTimeCount);
		Printf(s,"Simulation Cycles/Sec: %f" , (1000.0*(1.0/(float)((float)loopTime/(float)loopTimeCount))));
		return;
	}



	if (!strcmp(inp,"WHO")) 
	{
			if(now==0) 
			{
				Printf(s,"There are no users connected.\r\n");
				return;
			}

			int i, j=0;
			Printf(s,"Current Users in the World:\r\n");
			for (i=0;i<now;i++)
			{
				P_CHAR pc_i=MAKE_CHAR_REF(currchar[i]);				
				if( ISVALIDPC(pc_i) && clientInfo[i]->ingame ) //Keeps NPC's from appearing on the list
				{
					j++;
					Printf(s, "    %i) %s [%08x]\r\n", j, pc_i->getCurrentNameC(), pc_i->getSerial32());
				}
			}
			Printf(s, "Total Users Online: %d\r\n", j);
			Printf(s, "End of userlist\r\n");
			return;
	}

	if (!strcmp(inp,"QUIT") || !strcmp(inp, "EXIT")) 
	{ 
		Printf(s, "Bye %s ! :)\r\n\r\n", loginname[s]); 
		Disconnect(s); 
		return; 
	}

	if (!strcmp(inp,"HELP")) {
		Printf(s,"!! : repeats the last command\r\n");
		Printf(s,"WHO : displays logon players\r\n");
		Printf(s,"QUIT : close the connection\r\n");
		Printf(s,"EXIT : close the connection\r\n");
		Printf(s,"PDUMP : displays performance dump\r\n");
		Printf(s,"SAVE : saves the world\r\n");
		Printf(s,"SHUTDOWN : shuts the server\r\n");
		Printf(s,"ABORT : shuts the server WITHOUT saving\r\n");
		Printf(s,"BROADCAST, BC or '!' <msg> : broadcasts a message to everyone\r\n");
		Printf(s,"CFG <section>.<property>=<value> : sets a server.cfg setting dynamically\r\n");
		Printf(s,"ADDACCT <name>,<pwd> : creates a new account\r\n");
		Printf(s,"REMACCT <name> : remove an account\r\n");
		Printf(s,"CHANGEACCTPWD <name>,<pwd> : change an account password\r\n");
		Printf(s,"RELOADCRON : reloads the crontab.scp file\r\n");
		Printf(s,"AMXCALL <function> : executes a function of override.sma\r\n");
		Printf(s,"AMXRUN <program> : executes an external AMX program\r\n");
		Printf(s,"AMXBUILD <sourcefile> <outputprogram> : compiles a Small program\r\n");
		Printf(s,"RELOADBLOCKS : reload hosts_deny.scp\r\n");
		Printf(s,"RELOADSMALL : recompile and reload small scritps\r\n");

		return;
	}

	char tkn[1024];
	char *cmd = NULL, *par2 = NULL;
	

	for (i=0; i< strlen(inp); i++)
	{
		if (inp[i]==' ') 
		{
			tkn[i] = '\0';
			cmd = inp+i+1;
			break;
		} 
		else 
		{
			tkn[i]=inp[i];
		}
	}

	// before the splitting of arguments

	if (!strcmp(tkn,"CFG")) 
	{
		if ((cmd==NULL))
		{
			Printf(s,"Syntax is : CFG <section>.<property>=<value>\r\nExample : CFG SERVER.STATCAP=200\r\nSections and properties are the ones contained in server.scp\r\n");
			return;
		}
		int n=cfg_command(cmd);
		if (n!=0) 
			Printf(s, "Error number : %d\r\n", n);
		else 
			Printf(s, "OK.\r\n");

		return;
	}

	if (!strcmp(tkn,"AMXCALL")) 
	{
		if ((cmd==NULL)) 
		{
			Printf(s,"Syntax is : AMXCALL <function>\r\nExample : AMXCALL foo\r\n");
			return;
		}
		AmxFunction::g_prgOverride->CallFn(cmd);
		return;
	}

	if (!strcmp(tkn,"AMXRUN")) 
	{
		if ((cmd==NULL)) 
		{
			Printf(s,"Syntax is : AMXRUN <program>\r\nExample : AMXRUN myprog.amx\r\n");
			return;
		}
		AmxProgram *prg = new AmxProgram(cmd);
		prg->CallFn(-1);
		safedelete(prg);
		return;
	}

	if (cmd!=NULL) {
		for (i=0; i< strlen(cmd); i++)
		{
			if ((cmd[i]==',')||(cmd[i]==' ')) 
			{
				par2 = cmd+i+1;
				cmd[i] = '\0';
				break;
			}
		}
	}

	if (!strcmp(inp,"SAVE")) 
	{
			if ( !cwmWorldState->Saving() )
			{
				Printf(s, "Saving worldfile...");
				cwmWorldState->saveNewWorld();
				saveserverscript();
				Printf(s, "[DONE]\r\n");
				Printf(s, "OK.\r\n");
			} 
			return;
	}

	if (!strcmp(inp,"SHUTDOWN")) {
			ConOut("NoX-Wizard: Immediate Shutdown initialized from Remote Console!\n");
			Printf(s, "Bye! :)\r\n\r\n");
			keeprun=0;
			return;
	}

#ifdef DEBUG
	if (!strcmp(inp,"---CRASH")) { //this command is usefull to test crash recovery :)
			char *p = NULL;
			p[0] = 'X';
			Printf(s, "OK.\r\n");
			return;
	}
#endif

	if (!strcmp(inp,"ABORT")) 
	{
		exit(3);
		return;
	}

	if (!strcmp(inp,"RELOADCRON")) 
	{
			killCronTab();
			initCronTab();
			return;
	}


	if (!strcmp(inp,"RELOADBLOCKS")) 
	{
			Network->LoadHosts_deny();
			Printf(s,"hosts_deny.scp reloaded.");
			return;
	}									//wad }
	if (!strcmp(inp,"RELOADSMALL")) 
	{
			initAmxEvents();
			LoadOverrides ();
			AMXEXECV(AMXT_SPECIALS,0,AMX_AFTER);
			Printf(s,"Recompiled Small scripts");
			return;
	}									


	if ((!strcmp(tkn,"BROADCAST"))||(!strcmp(tkn,"BC"))||(!strcmp(tkn,"!"))) 
	{
			if ((cmd==NULL)) 
			{
				Printf(s,"Syntax is : BROADCAST <message>\r\nExample : BROADCAST Warning restarting server!\r\n");
				return;
			}

			if (par2!=NULL) 
				sysbroadcast("%s %s", cmd, par2);
			else 
				sysbroadcast("%s", cmd);

			Printf(s, "OK.\r\n");
			return;
	}

	if (!strcmp(tkn,"ADDACCT")) 
	{
		if ((cmd==NULL)||(par2==NULL)) 
		{
			Printf(s,"Syntax is : ADDACCT <name>,<password>\r\nExample : ADDACCT administrator,password\r\n");
			return;
		}
		int acc = Accounts->CreateAccount(cmd, par2);
		if ( acc != INVALID )
		{
			Printf(s, "Account %d created\r\n  Name : %s\r\n  Pass : %s\r\n", acc,cmd,par2);
			Printf(s, "[  OK  ] \r\n");
		}
		else
		{
			Printf(s, "Account %s not created. Username existant.\r\n", cmd);
			Printf(s, "[ERRORS]\r\n");
		}
		return;
	}
	
	if ( !strcmp(tkn,"REMACCT") )
	{
		if ((cmd==NULL))
		{
			Printf(s,"Syntax is : REMACCT <name>\r\nExample : REMACCT administrator\r\n");
			return;
		}
		if ( Accounts->RemoveAccount(cmd) )
		{
			Printf(s, "Account %s deleted\r\n", cmd);
			Printf(s, "[  OK  ]\r\n");
		}
		else
		{
			Printf(s, "Account %s not deleted\r\n", cmd);
			Printf(s, "[ERRORS]\r\n");
		}
		return;
	}
	
	if ( !strcmp(tkn,"CHANGEACCTPWD") )
	{
		if ((cmd==NULL)||(par2==NULL))
		{
			Printf(s,"Syntax is: CHANGEACCTPWD <name>,<password>\r\nExample : CHANGEACCTPWD administrator,newpassword\r\n");
			return;
		}
		ACCOUNT acc = Accounts->GetAccountByName(cmd);
		if ( acc != INVALID )
		{
			Accounts->ChangePassword(acc, par2);
			Printf(s, "Account %d has new password\r\n  Password : %s\r\n", acc, par2);
			Printf(s, "[  OK  ] \r\n");
		}
		else
		{
			Printf(s, "Password of account %s not changed. Username not existant.\r\n", cmd);
			Printf(s, "[ERRORS]\r\n");
		}
		return;
	}

	if (!strcmp(tkn,"AMXBUILD")) 
	{
		if ((cmd==NULL)||(par2==NULL)) 
		{
			Printf(s,"Syntax is : AMXBUILD <source> <output>\r\nExample : AMXBUILD myprog.sma myprog.amx\r\n");
			return;
		}
		Printf(s,"Initializing build : NOTE that output will go to the main console. Sorry for that :(\r\n");
		Printf(s,"Building...");
		char *argv[4];
		
		argv[0] = "noxwizard.internal.compiler";
		argv[1] = new char[50];
		argv[2] = new char[50];
		argv[3] = new char[50];

		strncpy(argv[1], cmd, 49);
		strncpy(argv[2], par2, 49);
		strncpy(argv[3], "", 49);

		int ret = compiler_main(3, (char **)argv);

		if (ret==0) 
			Printf(s,"[ OK ]\r\n");
		else if (ret==1) 
			Printf(s,"[WARNINGS]\r\n");
		else if (ret>1) 
			Printf(s,"[ERRORS]\r\n");

		delete argv[1];
		delete argv[2];
		delete argv[3];
		return;
	}

	Printf(s,"Unknown command entered.\r\n");
}