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

📄 account_wrap.c

📁 打魔兽战网的都知道他是什么
💻 C
📖 第 1 页 / 共 5 页
字号:
	char const *race = race_get_str(intrace);		if(!race)	    return 0;		sprintf(table,"Record\\%s\\%s\\losses",tag_uint_to_str(clienttag_str,clienttag),race);		return account_get_numattr(account,table);	}	extern int account_update_xp(t_account * account, t_clienttag clienttag, t_game_result gameresult, unsigned int opponlevel, int * xp_diff,t_ladder_id id){   int xp;  int mylevel;  int xpdiff = 0, placeholder;    xp = account_get_ladder_xp(account, clienttag,id); //get current xp  if (xp < 0) {    eventlog(eventlog_level_error, __FUNCTION__, "got negative XP");    return -1;  }     mylevel = account_get_ladder_level(account,clienttag,id); //get accounts level  if (mylevel > W3_XPCALC_MAXLEVEL) {    eventlog(eventlog_level_error, __FUNCTION__, "got invalid level: %d", mylevel);    return -1;  }    if(mylevel<=0) //if level is 0 then set it to 1    mylevel=1;    if (opponlevel < 1) opponlevel = 1;    switch (gameresult)     {    case game_result_win:      ladder_war3_xpdiff(mylevel, opponlevel, &xpdiff, &placeholder); break;    case game_result_loss:      ladder_war3_xpdiff(opponlevel, mylevel, &placeholder, &xpdiff); break;    default:      eventlog(eventlog_level_error, __FUNCTION__, "got invalid game result: %d", gameresult);      return -1;    }  *xp_diff = xpdiff;  xp += xpdiff;  if (xp < 0) xp = 0;  return account_set_ladder_xp(account,clienttag,id,xp);}extern int account_get_ladder_xp(t_account * account, t_clienttag clienttag, t_ladder_id id){    char key[256];    char clienttag_str[5];        sprintf(key,"Record\\%s\\%s\\xp",tag_uint_to_str(clienttag_str,clienttag),ladder_id_str[(int)id]);    return account_get_numattr(account,key);}extern int account_set_ladder_xp(t_account * account, t_clienttag clienttag, t_ladder_id id, unsigned int xp){    char         key[256];    char clienttag_str[5];        sprintf(key,"Record\\%s\\%s\\xp",tag_uint_to_str(clienttag_str,clienttag),ladder_id_str[(int)id]);    return account_set_numattr(account,key,xp);}extern int account_get_ladder_level(t_account * account, t_clienttag clienttag, t_ladder_id id){    char key[256];    char clienttag_str[5];        sprintf(key,"Record\\%s\\%s\\level",tag_uint_to_str(clienttag_str,clienttag),ladder_id_str[(int)id]);    return account_get_numattr(account,key);}extern int account_set_ladder_level(t_account * account, t_clienttag clienttag, t_ladder_id id, unsigned int level){    char         key[256];    char clienttag_str[5];        sprintf(key,"Record\\%s\\%s\\level",tag_uint_to_str(clienttag_str,clienttag),ladder_id_str[(int)id]);    return account_set_numattr(account,key,level);}extern int account_adjust_ladder_level(t_account * account, t_clienttag clienttag,t_ladder_id id){   int xp,mylevel;    xp = account_get_ladder_xp(account, clienttag,id);  if (xp < 0) xp = 0;     mylevel = account_get_ladder_level(account,clienttag,id);  if (mylevel < 1) mylevel = 1;     if (mylevel > W3_XPCALC_MAXLEVEL) {    eventlog(eventlog_level_error, __FUNCTION__, "got invalid level: %d", mylevel);    return -1;  }     mylevel = ladder_war3_updatelevel(mylevel, xp);  return account_set_ladder_level(account,clienttag,id,mylevel);}//Other funcs used in profiles and PG savingextern void account_get_raceicon(t_account * account, char * raceicon, unsigned int * raceiconnumber, unsigned int * wins, t_clienttag clienttag) //Based of wins for each race, Race with most wins, gets shown in chat channel{	unsigned int humans;	unsigned int orcs;	unsigned int undead;	unsigned int nightelf;	unsigned int random;	unsigned int i;	random = account_get_racewins(account,W3_RACE_RANDOM,clienttag);	humans = account_get_racewins(account,W3_RACE_HUMANS,clienttag); 	orcs = account_get_racewins(account,W3_RACE_ORCS,clienttag); 	undead = account_get_racewins(account,W3_RACE_UNDEAD,clienttag);	nightelf = account_get_racewins(account,W3_RACE_NIGHTELVES,clienttag);	if(orcs>=humans && orcs>=undead && orcs>=nightelf && orcs>=random) {	  *raceicon = 'O';	  *wins = orcs;	}	else if(humans>=orcs && humans>=undead && humans>=nightelf && humans>=random) {	    *raceicon = 'H';	    *wins = humans;	}	else if(nightelf>=humans && nightelf>=orcs && nightelf>=undead && nightelf>=random) {	    *raceicon = 'N';	    *wins = nightelf;	}	else if(undead>=humans && undead>=orcs && undead>=nightelf && undead>=random) {	    *raceicon = 'U';	    *wins = undead;	}	else {	    *raceicon = 'R';	    *wins = random;	}	i = 1;	while((signed)*wins >= anongame_infos_get_ICON_REQ(i,clienttag) && anongame_infos_get_ICON_REQ(i,clienttag) > 0) i++;	*raceiconnumber = i ;}extern int account_get_profile_calcs(t_account * account, int xp, unsigned int Level){        int xp_min;	int xp_max;	unsigned int i;	int  t;	unsigned int startlvl;		if (Level==1) startlvl = 1;	else startlvl = Level-1;	for (i = startlvl; i < W3_XPCALC_MAXLEVEL; i++) {		xp_min = ladder_war3_get_min_xp(i);		xp_max = ladder_war3_get_min_xp(i+1);		if ((xp >= xp_min) && (xp < xp_max)) {			t = (int)((((double)xp - (double)xp_min) 					/ ((double)xp_max - (double)xp_min)) * 128);			if (i < Level) {				return 128 + t;			} else {				return t;			}		}	}	return 0;}extern int account_set_saveladderstats(t_account * account,unsigned int gametype, t_game_result result, unsigned int opponlevel, t_clienttag clienttag){	unsigned int intrace;        int xpdiff,uid,level;	t_ladder_id id;	t_ladder * ladder;	if(!account) {		eventlog(eventlog_level_error, __FUNCTION__, "got NULL account");		return -1;	}	//added for better tracking down of problems with gameresults	eventlog(eventlog_level_trace,__FUNCTION__,"parsing game result for player: %s result: %s",account_get_name(account),(result==game_result_win)?"WIN":"LOSS");	intrace = account_get_w3pgrace(account, clienttag);	uid = account_get_uid(account);		switch (gametype)	{	  case ANONGAME_TYPE_1V1: //1v1	  {	  	id = ladder_id_solo;		ladder = solo_ladder(clienttag);		break;	  }	  case ANONGAME_TYPE_2V2:	  case ANONGAME_TYPE_3V3:	  case ANONGAME_TYPE_4V4:	  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:	  {	  	id = ladder_id_team;		ladder = team_ladder(clienttag);		break;	  }	  case ANONGAME_TYPE_SMALL_FFA:	  {	  	id = ladder_id_ffa;		ladder = ffa_ladder(clienttag);                break;	  }	  default:		eventlog(eventlog_level_error,__FUNCTION__,"Invalid Gametype? %u",gametype);		return -1;	}	if(result == game_result_win) //win	{		account_inc_ladder_wins(account, clienttag,id);		account_inc_racewins(account, intrace, clienttag);	}	if(result == game_result_loss) //loss	{		account_inc_ladder_losses(account, clienttag,id);		account_inc_racelosses(account,intrace, clienttag);	}			account_update_xp(account,clienttag,result,opponlevel,&xpdiff,id);	account_adjust_ladder_level(account,clienttag,id);	level = account_get_ladder_level(account,clienttag,id);	if (war3_ladder_update(ladder,uid,xpdiff,level,account,0)!=0)	  war3_ladder_add(ladder,uid,account_get_ladder_xp(account,clienttag,id),level,account,0,clienttag);	return 0;}extern int account_set_w3pgrace( t_account * account, t_clienttag clienttag, unsigned int race){  char key[256];  char clienttag_str[5];    sprintf(key,"Record\\%s\\w3pgrace",tag_uint_to_str(clienttag_str,clienttag));    return account_set_numattr( account, key, race);}extern int account_get_w3pgrace( t_account * account, t_clienttag clienttag ){  char key[256];  char clienttag_str[5];    sprintf(key,"Record\\%s\\w3pgrace",tag_uint_to_str(clienttag_str,clienttag));    return account_get_numattr( account, key);}// Arranged Team Functionsextern int account_set_currentatteam(t_account * account, unsigned int teamcount){	return account_set_numattr(account,"BNET\\current_at_team",teamcount);}extern int account_get_currentatteam(t_account * account){	return account_get_numattr(account,"BNET\\current_at_team");}extern int account_get_highestladderlevel(t_account * account,t_clienttag clienttag){	t_elem * curr;	t_team * team;	unsigned int sololevel = account_get_ladder_level(account,clienttag,ladder_id_solo);	unsigned int teamlevel = account_get_ladder_level(account,clienttag,ladder_id_team);	unsigned int ffalevel  = account_get_ladder_level(account,clienttag,ladder_id_ffa);	unsigned int atlevel = 0;	unsigned int t;		if (account_get_teams(account))	{		LIST_TRAVERSE(account_get_teams(account),curr)		{			if (!(team = elem_get_data(curr)))			{				eventlog(eventlog_level_error,__FUNCTION__,"found NULL entry in list");				continue;			}		if ((team_get_clienttag(team)!=clienttag))			continue;					if ((t = team_get_level(team)) > atlevel) 			atlevel = t;		}	}	eventlog(eventlog_level_debug,__FUNCTION__,"Checking for highest level in Solo,Team,FFA,AT Ladder Stats");	eventlog(eventlog_level_debug,__FUNCTION__,"Solo Level: %d, Team Level %d, FFA Level %d, Highest AT Team Level: %d",sololevel,teamlevel,ffalevel,atlevel);				if(sololevel >= teamlevel && sololevel >= atlevel && sololevel >= ffalevel)		return sololevel;	if(teamlevel >= sololevel && teamlevel >= atlevel && teamlevel >= ffalevel)        	return teamlevel;	if(atlevel >= sololevel && atlevel >= teamlevel && atlevel >= ffalevel)        	return atlevel;	return ffalevel;    // we should never get here	return -1;}//BlacKDicK 04/20/2003extern int account_set_user_icon( t_account * account, t_clienttag clienttag,char const * usericon){  char key[256];  char clienttag_str[5];    sprintf(key,"Record\\%s\\userselected_icon",tag_uint_to_str(clienttag_str,clienttag));  if (usericon)    return account_set_strattr(account,key,usericon);  else    return account_set_strattr(account,key,"NULL");}extern char const * account_get_user_icon( t_account * account, t_clienttag clienttag ){  char key[256];  char const * retval;  char clienttag_str[5];    sprintf(key,"Record\\%s\\userselected_icon",tag_uint_to_str(clienttag_str,clienttag));  retval = account_get_strattr(account,key);  if ((retval) && ((strcmp(retval,"NULL")!=0)))    return retval;  else    return NULL;}// Ramdom - Nothing, Grean Dragon Whelp, Azure Dragon (Blue Dragon), Red Dragon, Deathwing, Nothing// Humans - Peasant, Footman, Knight, Archmage, Medivh, Nothing// Orcs - Peon, Grunt, Tauren, Far Seer, Thrall, Nothing// Undead - Acolyle, Ghoul, Abomination, Lich, Tichondrius, Nothing// Night Elves - Wisp, Archer, Druid of the Claw, Priestess of the Moon, Furion Stormrage, Nothing// Demons - Nothing, ???(wich unit is nfgn), Infernal, Doom Guard, Pit Lord/Manaroth, Archimonde// ADDED TFT ICON BY DJP 07/16/2003static char * profile_code[12][6] = {	    {NULL  , "ngrd", "nadr", "nrdr", "nbwm", NULL  },	    {"hpea", "hfoo", "hkni", "Hamg", "nmed", NULL  },	    {"opeo", "ogru", "otau", "Ofar", "Othr", NULL  },	    {"uaco", "ugho", "uabo", "Ulic", "Utic", NULL  },	    {"ewsp", "earc", "edoc", "Emoo", "Efur", NULL  },	    {NULL  , "nfng", "ninf", "nbal", "Nplh", "Uwar"}, /* not used by RoC */	    {NULL  , "nmyr", "nnsw", "nhyc", "Hvsh", "Eevm"},	    {"hpea", "hrif", "hsor", "hspt", "Hblm", "Hjai"},	    {"opeo", "ohun", "oshm", "ospw", "Oshd", "Orex"},	    {"uaco", "ucry", "uban", "uobs", "Ucrl", "Usyl"},	    {"ewsp", "esen", "edot", "edry", "Ekee", "Ewrd"},	    {NULL  , "nfgu", "ninf", "nbal", "Nplh", "Uwar"}	};extern unsigned int account_get_icon_profile(t_account * account, t_clienttag clienttag){	unsigned int humans	= account_get_racewins(account,W3_RACE_HUMANS,clienttag);		//  1;	unsigned int orcs	= account_get_racewins(account,W3_RACE_ORCS,clienttag); 		        //  2;	unsigned int nightelf	= account_get_racewins(account,W3_RACE_NIGHTELVES,clienttag);	        //  4;	unsigned int undead	= account_get_racewins(account,W3_RACE_UNDEAD,clienttag);		//  8;	unsigned int random	= account_get_racewins(account,W3_RACE_RANDOM,clienttag);		// 32;	unsigned int race; 	     // 0 = Humans, 1 = Orcs, 2 = Night Elves, 3 = Undead, 4 = Ramdom	unsigned int level	= 0; // 0 = under 25, 1 = 25 to 249, 2 = 250 to 499, 3 = 500 to 1499, 4 = 1500 or more (wins)	unsigned int wins;	int number_ctag		= 0;	/* moved the check for orcs in the first place so people with 0 wins get peon */        if(orcs>=humans && orcs>=undead && orcs>=nightelf && orcs>=random) {            wins = orcs;            race = 2;        }        else if(humans>=orcs && humans>=undead && humans>=nightelf && humans>=random) {	    wins = humans;            race = 1;        }        else if(nightelf>=humans && nightelf>=orcs && nightelf>=undead && nightelf>=random) {            wins = nightelf;            race = 4;        }        else if(undead>=humans && undead>=orcs && undead>=nightelf && undead>=random) {            wins = undead;            race = 3;        }        else {            wins = random;            race = 0;        }        while(wins >= anongame_infos_get_ICON_REQ(level+1,clienttag) && anongame_infos_get_ICON_REQ(level+1,clienttag) > 0) level++;	if (clienttag == CLIENTTAG_WAR3XP_UINT)	  number_ctag = 6;                eventlog(eventlog_level_info,__FUNCTION__,"race -> %u; level -> %u; wins -> %u; profileicon -> %s", race, level, wins, profile_code[race+number_ctag][level]);	return char_icon_to_uint(profile_code[race+number_ctag][level]);}extern unsigned int account_icon_to_profile_icon(char const * icon,t_account * account, t_clienttag ctag){	char tmp_icon[4];	char * result;	int number_ctag=0;	if (icon==NULL) return account_get_icon_profile(account,ctag);	if (sizeof(icon)>=4){		strncpy(tmp_icon,icon,4);		tmp_icon[0]=tmp_icon[0]-48;		if (ctag==CLIENTTAG_WAR3XP_UINT) {			number_ctag = 6;		}		if (tmp_icon[0]>=1) {			if (tmp_icon[1]=='R'){				result = profile_code[0+number_ctag][tmp_icon[0]-1];			}else if (tmp_icon[1]=='H'){				result = profile_code[1+number_ctag][tmp_icon[0]-1];			}else if (tmp_icon[1]=='O'){				result = profile_code[2+number_ctag][tmp_icon[0]-1];			}else if (tmp_icon[1]=='U'){				result = profile_code[3+number_ctag][tmp_icon[0]-1];			}else if (tmp_icon[1]=='N'){				result = profile_code[4+number_ctag][tmp_icon[0]-1];			}else if (tmp_icon[1]=='D'){				result = profile_code[5+number_ctag][tmp_icon[0]-1];			}else{				eventlog(eventlog_level_warn,__FUNCTION__,"got unrecognized race on [%s] icon ",icon);				result = profile_code[2][0];} /* "opeo" */			}else{				eventlog(eventlog_level_warn,__FUNCTION__,"got race_level<1 on [%s] icon ",icon);				result = NULL;			}	}else{	    eventlog(eventlog_level_error,__FUNCTION__,"got invalid icon lenght [%s] icon ",icon);	    result = NULL;	}	//eventlog(eventlog_level_debug,__FUNCTION__,"from [%4.4s] icon returned [0x%X]",icon,char_icon_to_uint(result));	return char_icon_to_uint(result);}extern int account_is_operator_or_admin(t_account * account, char const * channel){   if ((account_get_auth_operator(account,channel)==1) || (account_get_auth_operator(account,NULL)==1) ||       (account_get_auth_admin(account,channel)==1) || (account_get_auth_admin(account,NULL

⌨️ 快捷键说明

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