예제 #1
0
void _PM_UpdateAimDownSightFlag() {
	#if 0
		void (*_BG_UpdateConditionValue)(int,int,int,qboolean);
		*(int*)&_BG_UpdateConditionValue = GAME("BG_UpdateConditionValue");
		
		qpmove_t *pp = (qpmove_t*)pm;
		qps *ps = pp->ps;
		
		int v3 = *(int*)(&ps->cmdtime + 180);
		
		//something = *(int *)( *(int *)&pml[132] + 716)
		
		if(ps->pm_type <= 5 && pp->cmd.buttons & 0x10 && /*&& something*/v3 != 2 && v3 != 1 && v3 != 10 && v3 != 11 /*&& (*(int *)&pml[48] || pm_type == 1) )*/) {
			if(ps->pm_flags & 1) {
				if(!pp->oldcmd.flags & 0x10 || !pp->oldcmd.serverTime) {
					ps->pm_flags |= 0x20;
					*(byte*)&ps->pm_flags |= 4;
				}
			} else {
				ps->pm_flags |= 0x20;
			}
		} else {
			ps->pm_flags &= 0xDFu;
		}
		
		//for animations
		if ( ps->pm_flags & 0x20 )
			_BG_UpdateConditionValue(*(int*)(ps + 172), 7, 1, 1);
		else
			_BG_UpdateConditionValue(*(int*)(ps + 172), 7, 0, 1);
	#endif
	
	int *pp = (int*)pm;
	int *ps = *pp;
	int *gclient = *ps;
	
	int *v4 = (int *)(ps + 12);
	
	int val = *(int*)(gclient + 21); //336? 84*4=336 /84/4=21??
	
	//Com_DPrintf("val = %d\n", val);
	
	if (val == 1023 && x_cl_adsair->integer) {
		*v4 |= 0x20;
		return;
	}
		
	void (*call)();
	*(int*)&call=GAME("PM_UpdateAimDownSightFlag");
	call();
}
예제 #2
0
void _Scr_FreeEntity(gentity_t *ent) {
	scr_entityfield_t *fields = (scr_entityfield_t*)( GAME("vmMain") + 0x28094 );
	for(int i = 0; fields[i].name; i++) {
		if(fields[i].type == 3)
			Scr_SetString((int*)((unsigned)ent + fields[i].offset), 0);
	}
	
	int i;
	for(i = 0; i < 6; i++) {
		*(unsigned char*)(i + (unsigned)ent + 748) = 0;
		Scr_SetString((int*)((unsigned)ent + (i*2) + 754), 0);
	}
	
	void (*FreeEntityNum)(int, int) = (void(*)(int,int isHudElem))GAME("Scr_FreeEntityNum");
	FreeEntityNum(ent->s.number, 0);
}
예제 #3
0
void set_user(object new_user) {
  if (!SYSTEM() && !COMMON() && !GAME()) {
    error("Tylko autoryzowany kod może zmieniać użytkownika!");
  }

  user = new_user;
}
예제 #4
0
void myClientCommand(int num) {
	/*
    Scr_AddInt(num);
    int result = Scr_ExecEntThread(num, 0, callbackPlayerCommand, 1);
    Scr_FreeThread(result);
	*/
	
    char cmd[MAX_STRING_CHARS];
    Cmd_ArgvBuffer(0, cmd, sizeof(cmd));
	
	//printf("%d[%s]\n", num, cmd);
    ENTITY* ent = game->getEntity(num);
	
	if(strcmp(cmd, "say") == 0) {
        char* saidn = ConcatArgs(1);
		char* said = &said[2];

        FILE *f = fopen("/home/cod/chatlog.txt", "a");
        if(f != NULL) {
            fprintf(f, "%d:", num);
            fprintf(f, said);
            fprintf(f, "\n");
            fclose(f);
        }
    } else if(strcmp(cmd, "codextended") == 0) {
        SV_SendServerCommand(num, 0, "e \"This server is running Call of Duty Extended\"");
        return;
    } else if(!strcmp(cmd, "god")) {
		Cmd_God(ent);
		return;
	}
	void (*call)(int);
	*((int*)(&call)) = GAME("ClientCommand");
	call(num);
}
예제 #5
0
int main(void) {

        startMenu();
        help();
        GAME();

        return 0;
}
예제 #6
0
void _PM_ClearAimDownSightFlag() {
	/*
	qpmove_t *pp = (qpmove_t*)pm;
	qps *ps = pp->ps;
	
	ps->pm_flags &= 0xDFu;
	*/
	if(!x_cl_adsair->integer)
		((void(*)())GAME("PM_ClearAimDownSightFlag"))();
}
예제 #7
0
void __dump_events() {
	char **events = (char**)GAME("eventnames");
	FILE *fp = fopen("/home/rawcod/event.dump", "w");
	if(!fp)
		return 0;
	int i ;
	for( i = 0; i < EV_MAX_EVENTS; i ++) {
		fprintf(fp, "\"%s\", //%d\n", events[i], i);
		fflush(fp);
	}
	fclose(fp);
}
예제 #8
0
static int PM_CheckJump() {
	pmove_t *xm = *(pmove_t**)(int)pm;
	#if 0
	if(xm->cmd.wbuttons & WBUTTON_RELOAD) {
		
		return 0;
		
	}
	#endif
	
	int (*cj)() = (int(*)())GAME("BG_PlayerTouchesItem") + 0x7DC;
	return cj();
}
gboolean start_timeout(gpointer data) {
    GameNetworkPlayerManager * manager;
    GameNetworkPlayer * game;

    manager = GAME_NETWORK_PLAYER_MANAGER(data);


    UiMain * ui_main =  ui_main_get_instance();

    PRIVATE(manager)->playing = TRUE;

  
    g_print("start_timeout\n");

    monkey_canvas_clear( PRIVATE(manager)->canvas);
    monkey_canvas_paint( PRIVATE(manager)->canvas);
    
    game = game_network_player_new( PRIVATE(manager)->window,
				    PRIVATE(manager)->canvas,
				    PRIVATE(manager)->monkey,
				    PRIVATE(manager)->handler,
				    PRIVATE(manager)->client_id,
				    PRIVATE(manager)->current_score);
    ui_main_set_game(ui_main,GAME( game));


    monkey_canvas_paint( PRIVATE(manager)->canvas);

    game_start( GAME(game) );
  
    game_network_player_set_start_time(game,PRIVATE(manager)->start_time);

    g_signal_connect( G_OBJECT(game), "state-changed",
		      G_CALLBACK(state_changed),manager);
    PRIVATE(manager)->current_game = game;

    return FALSE;
}
예제 #10
0
void load(mapping data)
{
	ACCESS_CHECK(GAME());

	set_archetypes(data["archetypes"]);
	set_virtual(data["virtual"]);
	set_capacity(data["capacity"]);
	set_density(data["density"]);
	set_flexible(data["flexible"]);
	set_id(data["id"]);
	rearrange_inventory(data["inventory"]);
	set_mass(data["mass"]);
	set_max_mass(data["max_mass"]);
	set_local_properties(data["properties"]);
}
void
game_network_player_manager_stop(GameManager * g) 
{
    GameNetworkPlayerManager * manager;
    UiMain * ui_main =  ui_main_get_instance();


    manager = GAME_NETWORK_PLAYER_MANAGER(g);
    game_stop( GAME(PRIVATE(manager)->current_game));

    g_signal_handlers_disconnect_matched(  G_OBJECT( PRIVATE(manager)->current_game ),
					   G_SIGNAL_MATCH_DATA,0,0,NULL,NULL,manager);

    g_object_unref( PRIVATE(manager)->current_game);
    PRIVATE(manager)->current_game = NULL;
    ui_main_set_game(ui_main,NULL);
}
예제 #12
0
mapping save()
{
	ACCESS_CHECK(GAME());

	return ([
		"archetypes": query_archetypes(),
		"capacity": query_capacity(),
		"density": query_density(),
		"environment": query_environment(),
		"flexible": query_flexible(),
		"id": query_id(),
		"inventory": query_inventory(),
		"mass": query_mass(),
		"max_mass": query_max_mass(),
		"name": query_object_name(),
		"properties": query_local_properties(),
		"virtual": query_virtual()
	]);
}
예제 #13
0
void set_body(object new_body)
{
	object *mobiles;

	ACCESS_CHECK(TEXT() || GAME() || VERB());

	if (body) {
		mobiles = body->query_property("mobiles");

		if (mobiles) {
			mobiles -= ({ this_object(), nil });

			if (!sizeof(mobiles)) {
				mobiles = nil;
			}

			body->set_property("mobiles", mobiles);
		}
	}
예제 #14
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
}
예제 #15
0
void set_mobile(object new_mobile)
{
	ACCESS_CHECK(TEXT() || GAME() || VERB());

	mobile = new_mobile;
}
예제 #16
0
void RunnableManager::Initialize() {
    GenericAsyncTask *task = new GenericAsyncTask(string("RunnableManager"), (TaskFunc)&TaskUpdate, NULL);
    GAME()->taskMgr().add(task);
    last_time_ = 0.0;
}
예제 #17
0
void set_meat_locker(int new_ml) {
  if(GAME())
    meat_locker = new_ml;
  else
    error("Can't call function!  Not authorized!");
}
예제 #18
0
void _SpectatorClientEndFrame(gentity_t *ent) {
	void (*orig)(gentity_t*) = (void(*)(gentity_t*))GAME("SpectatorClientEndFrame");
	orig(ent);
	
//	VectorCopy(tmp_vec, ent->client->ps.origin); //so u can set origin in killcam/spectate mode
	
	#if 0
	//clientsize = 16868, gclientsize orig = 8400

	char client[0x20D0] = {0};
	#define GCLIENT_SIZE 0x20d0
	//gclient_t client;
	static bool once = 0;
	if(!once) {
		printf("clientsize = %d, gclientsize orig = %d\n", sizeof(gclient_t), GCLIENT_SIZE);
		once = true;
	}
	void (*_HudElem_UpdateClient)(playerState_t *, int, int) = (void(*)(playerState_t*,int,int))GAME("HudElem_UpdateClient");
	void (*_StopFollowing)(gentity_t*) = (void(*)(gentity_t*))GAME("StopFollowing");
	int (*GetArchivedPlayerState)(int,int*,char *) = (int(*)(int,int*,char*))GAME("trap_GetArchivedPlayerState");
	ent->svFlags = ent->svFlags & 0xFD | 1;
	ent->takedamage = 0;
	ent->contents = 0;
	ent->client->field_220C = 0;
	ent->client->field_2210 = 0;
	ent->client->ps.field_BC = 0;
	
	ent->client->ps.pm_flags &= 0xfb;
	
	if(ent->client->spectatorClient < 0) {
		LABEL_9:
		if(ent->client->forceSpectatorClient < 0) {
			_StopFollowing(ent);
			return;
		}
		
		if(!GetArchivedPlayerState(ent->client->forceSpectatorClient, &ent->client->archivetime, &client)) {
			_StopFollowing(ent);
			return;
		}
	} else {
		
		ent->client->forceSpectatorClient = ent->client->spectatorClient;
		while(1) {
			if(ent->client->archivetime < 0)
				ent->client->archivetime = 0;
			if(GetArchivedPlayerState(ent->client->spectatorClient, &ent->client->archivetime, &client))
				break;
			if(!ent->client->archivetime) {
				ent->client->spectatorClient = -1;
				ent->client->forceSpectatorClient = -1;
				goto LABEL_9;
			}
			ent->client->archivetime -= 50;
		}
	}
	
	int savedFlags = ent->client->ps.eFlags & 0x20000 | (0xFFFDFFFF);
	memcpy(ent->client, &client, sizeof(client));
	//VectorCopy(client.ps.viewangles, ent->client->ps.viewangles);
	_HudElem_UpdateClient(&ent->client->ps, ent->s.number, 2);
	ent->client->ps.pm_flags &= 0xfb;
	ent->client->ps.pm_flags |= 1;
	if(ent->client->spectatorClient >= 0)
		ent->client->ps.pm_flags |= 2;
	else
		ent->client->ps.pm_flags &= 0xfd;
	ent->client->ps.eFlags = savedFlags;
	#endif
}
예제 #19
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);
}
예제 #20
0
static void PM_Weapon( void ) {
	pmove_t *xm = *(pmove_t**)(int)pm;
	
	int *weaponstate = (int*)((int)xm->ps + 180);
	int *weapons = *(int**)((int)xm->ps + 796);
	int *weapon = (int*)((int)xm->ps + 176);
	int *weaponTime = (int*)((int)xm->ps + 44);
	int *weaponDelay = (int*)((int)xm->ps + 48);
	int prestate = *weaponstate;
	
	playerState_t *ps = xm->ps;
	
	int clientNum = *(int*)((int)ps + 172);
	client_t *cl = getclient( clientNum );
	gentity_t *ent = &g_entities[clientNum];
	
	gclient_t *gclient = ent->client;
	
	void (*o)() = (void(*)())GAME("PM_Weapon");
	o();
	
	#if 1
	if((cl->lastUsercmd.buttons & 0x40) == 0x40) { //usebuttonpressed
		if(!xclients[clientNum].sprinting) {
			
			*(int*)((int)gclient + 180) = WEAPON_RECHAMBERING;
			*(int*)((int)gclient + 980) = WEAP_ALTSWITCHFROM;
			
			*(float*)((int)gclient + 848) = 1.35; //runspeedscale?
			//*(int*)((int)gclient + 828) = //prone
			//*(int*)((int)gclient + 832) = //crouch;
			//*(int*)((int)gclient + 836) = 100;//standing;
			xclients[clientNum].sprinting = 1;
			return;
		}
	} else {
		if(xclients[clientNum].sprinting) {
			*(int*)((int)gclient + 180) = WEAPON_READY;
			*(int*)((int)gclient + 980) = WEAP_IDLE;
			*(float*)((int)gclient + 848) = 1; //runspeedscale?
			xclients[clientNum].sprinting = 0;
			
			return;
		}
	}
	#endif
	
	//prob shouldnt include interrupts
	if(xclients[clientNum].perks[PERK_QUICK_RELOAD] && (prestate == WEAPON_RELOADING || prestate == WEAPON_RELOAD_END || prestate == WEAPON_RELOAD_START || prestate == WEAPON_RECHAMBERING) && (!*weaponDelay || !*weaponTime)) {
		*(int*)((int)gclient + 980) = 17;
	}
	
	/*
	client_t *cl = getclient( clientNum );
	
	xentity_t *xent = &xentities[clientNum];
	gentity_t *ent = g_entities(clientNum);
	gclient_t *gclient = ent->client;
	
	//if(*(int*)((int)ps + 8680) & 0x20 && cl->lastUsercmd.wbuttons & 0x8) {
	if(xent->sprinting) {
		*(int*)((int)gclient + 180) = WEAPON_RECHAMBERING;
		*(int*)((int)gclient + 980) = WEAP_ALTSWITCHFROM;
		
		//*(int*)((int)gclient + 828) = //prone
		//*(int*)((int)gclient + 832) = //crouch;
		//*(int*)((int)gclient + 836) = 100;//standing;
		return;
	}
	
	//*(int*)((int)gclient + 836) = 60;//standing;
	*/
	
}
예제 #21
0
void set_start_room(int new_sr) {
  if(GAME())
    start_room = new_sr;
  else
    error("Can't call function!  Not authorized!");
}
예제 #22
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
}