⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 anongame.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 5 页
字号:
	    if (!discs && wins != 2) {		eventlog(eventlog_level_info, __FUNCTION__, "bogus game result: wins != 2 in team ffa game");		return -1;	    }	    break;	default:	    if (!discs && wins > losses) {		eventlog(eventlog_level_info, __FUNCTION__, "bogus game result: wins > losses");		return -1;	    }	    break;    }    /* prevent users from getting loss if server is shutdown (does not prevent errors from crash) - [Omega] */    /* also discard games with no winners at all (i.e. games where game host disc'ed and so all players do) */    if (!wins)	return -1;    /* according to zap, order of players in anongame is:     * for PG: t1_p1, t2_p1, t1_p2, t2_p2, ...     * for AT: t1_p1, t1_p2, ..., t2_p1, t2_p2, ...     *     * (Not True.. follows same order as PG)     *  4v4     = t1_p1, t2_p1, t1_p2, t2_p2, t1_p3, t2_p3, t1_p4, t2_p4     *  3v3v3   = t1_p1, t2_p1, t3_p1, t1_p2, t2_p2, t3_p2, t1_p3, t2_p3, t3_p3     *  2v2v2v2 = t1_p1, t2_p1, t3_p1, t4_p1, t1_p2, t2_p2, t3_p2, t4_p2     */    /* opponent level calculation has to be done here, because later on, the level of other players     * may allready be modified     */    for (i = 0; i < tp; i++) {	int j, k, l;	t_account *oacc;	oppon_level[i] = 0;	switch (gametype) {	    case ANONGAME_TYPE_TY:		/* FIXME-TY: ADD TOURNAMENT STATS RECORDING (this part not required?) */		break;	    case ANONGAME_TYPE_1V1:		oppon_level[i] = account_get_ladder_level(a->info->account[(i + 1) % tp], ct, ladder_id_solo);		break;	    case ANONGAME_TYPE_SMALL_FFA:		/* oppon_level = average level of all other players */		for (j = 0; j < tp; j++)		    if (i != j)			oppon_level[i] += account_get_ladder_level(a->info->account[j], ct, ladder_id_ffa);		oppon_level[i] /= (tp - 1);		break;	    case ANONGAME_TYPE_AT_2V2:	    case ANONGAME_TYPE_AT_3V3:	    case ANONGAME_TYPE_AT_4V4:		oacc = a->info->account[(i + 1) % tp];		oppon_level[i] = team_get_level(account_find_team_by_teamid(oacc, account_get_currentatteam(oacc)));		break;	    case ANONGAME_TYPE_AT_2V2V2:		oacc = a->info->account[(i + 1) % tp];		oppon_level[i] = team_get_level(account_find_team_by_teamid(oacc, account_get_currentatteam(oacc)));		oacc = a->info->account[(i + 2) % tp];		oppon_level[i] = team_get_level(account_find_team_by_teamid(oacc, account_get_currentatteam(oacc)));		oppon_level[i] /= 2;		break;	    default:		/* oppon_level = average level of all opponents		 * this should work for all PG team games		 * [Omega] */		k = i + 1;		for (j = 0; j < (tp / tt); j++) {		    for (l = 0; l < (tt - 1); l++) {			oppon_level[i] += account_get_ladder_level(a->info->account[k % tp], ct, ladder_id_team);			k++;		    }		    k++;		}		oppon_level[i] /= (tp / tt * (tt - 1));	}    }    for (i = 0; i < tp; i++) {	t_account *acc;	t_team *team;	unsigned int currteam;	int result = a->info->result[i];	if (result == -1)	    result = W3_GAMERESULT_LOSS;	acc = a->info->account[i];	switch (gametype) {	    case ANONGAME_TYPE_TY:		if (result == W3_GAMERESULT_WIN)		    tournament_add_stat(acc, 1);		if (result == W3_GAMERESULT_LOSS)		    tournament_add_stat(acc, 2);		/* FIXME-TY: how to do ties? */		break;	    case ANONGAME_TYPE_AT_2V2:	    case ANONGAME_TYPE_AT_3V3:	    case ANONGAME_TYPE_AT_4V4:	    case ANONGAME_TYPE_AT_2V2V2:		if ((currteam = account_get_currentatteam(acc))) {		    team = account_find_team_by_teamid(acc, currteam);		    team_set_saveladderstats(team, gametype, result, oppon_level[i], ct);		}		break;	    case ANONGAME_TYPE_1V1:	    case ANONGAME_TYPE_2V2:	    case ANONGAME_TYPE_3V3:	    case ANONGAME_TYPE_4V4:	    case ANONGAME_TYPE_SMALL_FFA:	    case ANONGAME_TYPE_5V5:	    case ANONGAME_TYPE_6V6:	    case ANONGAME_TYPE_2V2V2:	    case ANONGAME_TYPE_3V3V3:	    case ANONGAME_TYPE_4V4V4:	    case ANONGAME_TYPE_2V2V2V2:	    case ANONGAME_TYPE_3V3V3V3:		if (result == W3_GAMERESULT_WIN)		    account_set_saveladderstats(acc, gametype, game_result_win, oppon_level[i], ct);		if (result == W3_GAMERESULT_LOSS)		    account_set_saveladderstats(acc, gametype, game_result_loss, oppon_level[i], ct);		break;	    default:		break;	}    }    /* aaron: now update war3 ladders */    ladder_update_all_accounts();    return 1;}/**********/extern t_anongameinfo *anongameinfo_create(int totalplayers){    t_anongameinfo *temp;    int i;    temp = xmalloc(sizeof(t_anongameinfo));    temp->totalplayers = temp->currentplayers = totalplayers;    for (i = 0; i < ANONGAME_MAX_GAMECOUNT; i++) {	temp->player[i] = NULL;	temp->account[i] = NULL;	temp->result[i] = -1;	/* consider DISC default */	temp->results[i] = NULL;    }    return temp;}extern void anongameinfo_destroy(t_anongameinfo * i){    int j;    if (!i) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongameinfo");	return;    }    for (j = 0; j < ANONGAME_MAX_GAMECOUNT; j++)	if (i->results[j])	    gameresult_destroy(i->results[j]);    xfree(i);}/**********/extern t_anongameinfo *anongame_get_info(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return NULL;    }    return a->info;}extern int anongame_get_currentplayers(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    if (!a->info) {	eventlog(eventlog_level_error, __FUNCTION__, "NULL anongameinfo");	return 0;    }    return a->info->currentplayers;}extern int anongame_get_totalplayers(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    if (!a->info) {	eventlog(eventlog_level_error, __FUNCTION__, "NULL anongameinfo");	return 0;    }    return a->info->totalplayers;}extern t_connection *anongame_get_player(t_anongame * a, int plnum){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return NULL;    }    if (!a->info) {	eventlog(eventlog_level_error, __FUNCTION__, "NULL anongameinfo");	return NULL;    }    if (plnum < 0 || plnum > 7 || plnum >= a->info->totalplayers) {	eventlog(eventlog_level_error, __FUNCTION__, "invalid plnum: %d", plnum);	return NULL;    }    return a->info->player[plnum];}extern int anongame_get_count(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->count;}extern t_uint32 anongame_get_id(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->id;}extern t_connection *anongame_get_tc(t_anongame * a, int tpnumber){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->tc[tpnumber];}extern t_uint32 anongame_get_race(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->race;}extern t_uint32 anongame_get_handle(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->handle;}extern unsigned int anongame_get_addr(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->addr;}extern char anongame_get_loaded(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->loaded;}extern char anongame_get_joined(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->joined;}extern t_uint8 anongame_get_playernum(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->playernum;}extern t_uint8 anongame_get_queue(t_anongame * a){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return 0;    }    return a->queue;}/**********/extern void anongame_set_result(t_anongame * a, int result){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return;    }    if (!a->info) {	eventlog(eventlog_level_error, __FUNCTION__, "NULL anongameinfo");	return;    }    if (a->playernum < 1 || a->playernum > ANONGAME_MAX_GAMECOUNT) {	eventlog(eventlog_level_error, __FUNCTION__, "invalid playernum: %d", a->playernum);	return;    }    a->info->result[a->playernum - 1] = result;}extern void anongame_set_gameresults(t_anongame * a, t_anongame_gameresult * results){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return;    }    if (!a->info) {	eventlog(eventlog_level_error, __FUNCTION__, "NULL anongameinfo");	return;    }    if (a->playernum < 1 || a->playernum > ANONGAME_MAX_GAMECOUNT) {	eventlog(eventlog_level_error, __FUNCTION__, "invalid playernum: %d", a->playernum);	return;    }    a->info->results[a->playernum - 1] = results;}extern void anongame_set_handle(t_anongame * a, t_uint32 h){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return;    }    a->handle = h;}extern void anongame_set_addr(t_anongame * a, unsigned int addr){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return;    }    a->addr = addr;}extern void anongame_set_loaded(t_anongame * a, char loaded){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return;    }    a->loaded = loaded;}extern void anongame_set_joined(t_anongame * a, char joined){    if (!a) {	eventlog(eventlog_level_error, __FUNCTION__, "got NULL anongame");	return;    }    a->joined = joined;}/**********//* move to own .c/.h file for handling w3route connections */extern int handle_w3route_packet(t_connection * c, t_packet const *const packet){/* [smith] 20030427 fixed Big-Endian/Little-Endian conversion (Solaris bug) then  * use  packet_append_data for append platform dependent data types - like  * "int", cos this code was broken for BE platforms. it's rewriten in platform  * independent style whis usege bn_int and other bn_* like datatypes and  * fuctions for wor with datatypes - bn_int_set(), what provide right 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -