Ejemplo n.º 1
0
void set_trap_func_ptr( void ) {
	T_SetBrushModel = (T_SetBrushModel_t)GAME("trap_SetBrushModel");
	T_LinkEntity = (T_LinkEntity_t)GAME("trap_LinkEntity");
	T_UnlinkEntity = (T_UnlinkEntity_t)GAME("trap_UnlinkEntity");
	G_Spawn = (G_Spawn_t)GAME("G_Spawn");
	G_SetOrigin = (G_SetOrigin_t)GAME("G_SetOrigin");
	G_SetAngle = (G_SetAngle_t)GAME("G_SetAngle");
	BG_EvaluateTrajectory = (BG_EvaluateTrajectory_t)GAME("BG_EvaluateTrajectory");
	BG_EvaluateTrajectoryDelta = (BG_EvaluateTrajectoryDelta_t)GAME("BG_EvaluateTrajectoryDelta");
	
	G_FreeEntity = (G_FreeEntity_t)GAME("G_FreeEntity");
	
	void _Scr_FreeEntity(gentity_t*);
	__jmp(GAME("Scr_FreeEntity"), (unsigned)_Scr_FreeEntity);
	void _SpectatorClientEndFrame(gentity_t*);
	//__jmp(GAME("SpectatorClientEndFrame"), _SpectatorClientEndFrame);
	__call(GAME("ClientEndFrame")+0x98, (unsigned)_SpectatorClientEndFrame);
	
	#if 0
	scr_entityfield_t *fields = (scr_entityfield_t*)( GAME("vmMain") + 0x28094 );
	FILE *fp = fopen("entfields.txt", "w");
	
	fprintf(fp, "scr_entityfield_t scr_entityfields[] = {\n");
	for(int i = 0; fields[i].name; i++) {
		fprintf(fp, "{\"%s\", %u, %u, %x},\n", fields[i].name, fields[i].offset, fields[i].type, fields[i].set);
	}
	fprintf(fp, "};\n");
	fclose(fp);
	#endif
}
Ejemplo n.º 2
0
void database_ssdb::__construct(const php::parameter& param) {
    php::value conf = param[0];
    std::string host = conf["host"];
    zend_long   port = conf["port"];
    if(host.empty() || port <= 0 || port > 65535) {
        zend_throw_error(nullptr, "illegal ssdb config #3");
        return;
    }
    int timeout = 2000;
    if(conf.__isset("timeout")) {
        timeout = (long)conf["timeout"];
    }
    pssdb = ssdb::Client::connect(host, port, timeout);
    if(pssdb == nullptr) {
        zend_throw_error(nullptr, "ssd failed to connect ssdb");
        return;
    }
    if(conf.__isset("auth")) {
        php::parameter auth(conf["auth"].intern(), 1);
        __call("auth", auth);
    }
    prefix = (std::string)conf["prefix"];
    // 保存一个属性,方便客户端调用
    php::property prop(this);
    prop.oset("prefix", prefix);
}
Ejemplo n.º 3
0
    //    helper function dirExists(dirPath)
    any mkPath_dirExists(DEFAULT_ARGUMENTS){
        // define named params
        var dirPath = argc>0? arguments[0] : undefined;
        //---------
         try{

        //if fs.statSync(dirPath).isDirectory()
        if (_anyToBool(__call(isDirectory_,fs_statSync(undefined,1,(any_arr){dirPath}),0,NULL)))  {
        
            //return true //ok! exists and is a directory
            {e4c_exitTry(1);return true;};
            
        }
        //else
        //else
        
        else {
            //throw new Error('#{dirPath} exists but IT IS NOT a directory')
            throw(new(Error,1,(any_arr){_concatAny(2,dirPath,any_LTR(" exists but IT IS NOT a directory"))}));
            
        };

        //exception err
        
        }catch(err){

            //if dir does not exists, return false
            //if err.code is 'ENOENT', return false
            if (__is(code__(err),any_LTR("ENOENT"))) {{e4c_exitTry(1);return false;};};
            //throw err //another error
            throw(err);
            
        };
        
    return undefined;
    }
Ejemplo n.º 4
0
void BG_Link() {
	#ifdef xDEBUG
	Cmd_AddCommand("debug_dumpevents", __dump_events);
	#endif

	BG_GetNumWeapons = (int(*)())GAME("BG_GetNumWeapons");
	BG_GetInfoForWeapon = (int(*)(int))GAME("BG_GetInfoForWeapon");
	BG_AnimScriptEvent = (int(*)(playerState_t*,int,int,int))GAME("BG_AnimScriptEvent");
	PM_AddEvent = (void(*)(int))GAME("PM_AddEvent");
	
	//sub_37488
	//GAME("PM_InteruptWeaponWithProneMove");
	
	PM_SetReloadingState2 = (void(*)())GAME("PM_InteruptWeaponWithProneMove") + 0x434;
	PM_SetWeaponReloadAddAmmoDelay = (void(*)())GAME("PM_InteruptWeaponWithProneMove") + 0x330;
	
	#ifdef xDEBUG
	__jmp(GAME("PM_InteruptWeaponWithProneMove") + 0x434, (int)PM_SetReloadingState);
	__jmp(GAME("PM_InteruptWeaponWithProneMove") + 0x530, (int)PM_BeginWeaponReload);
	//__jmp(GAME("PM_InteruptWeaponWithProneMove") + 0x148, (int)PM_Weapon_CheckForRechamber);
	
	__call(GAME("PmoveSingle")+0x455, (int)PM_Weapon);
	__call(GAME("PmoveSingle")+0x535, (int)PM_Weapon);
	
	__call(GAME("BG_PlayerTouchesItem") + 0xEA5, (int)PM_CheckJump);
	#endif
	/*
		aim in air if client allows it
		maybe add a groundEntityNum = 1023; force???
		- Richard
	*/
	//__jmp( dlsym(gamelib, "PM_UpdateAimDownSightFlag"), _PM_UpdateAimDownSightFlag);
	int thk = GAME("PmoveSingle");
	__call(thk + 0x3cc, _PM_UpdateAimDownSightFlag);
	__call(thk + 0x3ea, _PM_UpdateAimDownSightFlag);
	__call(thk + 0x404, _PM_UpdateAimDownSightFlag);
	__call(thk + 0x441, _PM_UpdateAimDownSightFlag);
	__call(thk + 0x49e, _PM_UpdateAimDownSightFlag);
	__call(thk + 0x4d7, _PM_UpdateAimDownSightFlag);
	//__jmp( GAME("PM_ClearAimDownSightFlag"), _PM_ClearAimDownSightFlag);
	__call( thk + 0xFD, _PM_ClearAimDownSightFlag);
	__call( GAME("vmMain") - 0x1F119, _PM_ClearAimDownSightFlag);
}
Ejemplo n.º 5
0
void set_game_ptr( void *ret ) {
	
	char libn[512];
	char* check = Cvar_VariableString("fs_game");
	if(check[0] == '\0')
		sprintf(libn, "main/game.mp.i386.so");
	else
		sprintf(libn, "%s/game.mp.i386.so", check);
	//char* libn = "/home/cod/codextended/game.mp.i386.so";
	int unprotect_lib(char *libname);
	unprotect_lib(libn);
	
	//mprotect(ret, 0x8A400, PROT_READ | PROT_WRITE | PROT_EXEC);
	gamelib = ret;
	base = (int)dlsym(ret, "vmMain"); //0x4D84C
	g_entities = (gentity_t*)dlsym(ret, "g_entities");
	level = (level_locals_t*)GAME("level");
	pml = (char (*)[140])dlsym(ret, "pml");
	pm = (pmove_t*)dlsym(ret, "pm");
	
	void BG_Link();
	BG_Link();
	
	void init_g_spawn();
	init_g_spawn();
	set_trap_func_ptr();
	scriptInitializing();
	
	
	//__nop(GAME("ClientEndFrame")+0x253,3); //mov g_Speed > ps->speed
	
	
	int stuck = (int)dlsym(ret, "StuckInClient");
	__jmp(stuck, (int)StuckInPlayer);
	
	int cont = (int)dlsym(ret, "G_SetClientContents");
	__jmp(cont, (int)G_SetPlayerContents);
	
	
	int h66 = (int)dlsym(ret, "ClientEndFrame") + 0x173; //patch contents
	__nop(h66, h66+0xa);
	
	#if 0
	{
		//ClientCommand+54F  24FC                mov     eax, [esi+158h]
		unsigned off = (unsigned)(dlsym(gamelib, "ClientCommand") + 0x54f);
		unsigned end = (unsigned)(dlsym(gamelib, "ClientCommand") + 0x5B4 + 2);
		
		__nop(off, end - off);
		__call(off, 
	}
	#endif
	
	//int h93 = GAME("PM_Weapon")+0x63;
	//__nop(h93,h93+5);
	
	__call(GAME("ClientCommand")+0x62D, (int)Cmd_CallVote);
	
	void ClientBegin(int);
	__call(GAME("vmMain")+0xA0, (int)ClientBegin);
	
	/*
		Newline, carriage return say fix.
	*/
	
	int clientcommand_off = GAME("ClientCommand");
	
	__call(clientcommand_off + 0x6EE, (int)hG_Say);
	__call(clientcommand_off + 0x6FE, (int)hG_Say);
	
	int g_say_off = GAME("G_Say");
	__call(g_say_off + 0x5EA, (int)hG_Say);
	__call(g_say_off + 0x791, (int)hG_Say);
	__call(g_say_off + 0x77D, (int)hG_Say);
	
	/*
		only one left to patch should be 
			
			Cmd_GameCommand_f+84 call    G_Say           ; Call Procedure
			Cmd_GameCommand_f+94 call    G_Say           ; Call Procedure
			
		since we're already ignoring the 'gc' command no need to
	*/
	
	/*
		End of fix
			- Richard
		//i should add more comments to make things more clearer for me when i look at the code later again. :3
	*/
	
	/*
		q3msgboom || codmsgboom fix
	*/
	int q21 = GAME("G_Say")+0x50e;
	int q22 = GAME("G_Say")+0x5ca;
	*(int*)q21=0x37f;
	*(int*)q22=0x37f;
	
	__jmp(GAME("G_Printf"), printf);
	
	/*
		end of fix
	*/
	
	x_deadchat = Cvar_Get("x_deadchat", "1", 0);
	
	//deadchat fix
	int b2 = GAME("G_SayTo")+0x70;
	__nop(b2, b2+2);
	
	int b3 = GAME("G_Say")+0x3B6;
	int b4 = GAME("G_Say")+0x2B3;
	*(byte*)b3 = 0xeb;
	*(byte*)b4 = 0xeb;
	
	//end deadchat fix
	
	/*
		Spectator noclip
	*/
	
	if(x_spectator_noclip->integer) {
		int y7 = GAME("SpectatorThink")+0x123;
		*(int*)y7 = 0;
	}
	
	#if 0
	#define DB_SERVER "localhost"
	#define DB_USER "root"
	#define DB_DATABASE "cod1"
	#endif
	cvar_t* db_password = Cvar_Get("db_password","",0);
	cvar_t* db_username = Cvar_Get("db_username","root",0);
	cvar_t* db_database = Cvar_Get("db_database","",0);
	cvar_t* db_server = Cvar_Get("db_server","localhost",0);
	
	#ifdef uMYSQL
	static int sql_do_once = 0;
	
	if(!sql_do_once) {
		if(mysql_real_connect(db,db_server->string,db_username->string,db_password->string,db_database->string,0,NULL,0) == NULL) {
			printf("Could not connect to the MySQL Database. [Error: %s]\n", mysql_error(db));
			//COD_Destructor();
			mysql_close(db);
			db = NULL;
		} else {
			printf("Connected to the MySQL Database.\n");
		}
		sql_do_once = 1;
	}
	#endif
}