TEG_STATUS attack_click( PCOUNTRY p ) { if( attack_check() != TEG_STATUS_SUCCESS ) { textmsg(M_ERR,_("Error, It's not the time to attack")); return TEG_STATUS_UNEXPECTED; } if( country_origen == -1 ) { if(p->numjug == WHOAMI()) { if( p->ejercitos >1 ) { p->selected &= ~COUNTRY_SELECT_ATTACK_ENTER; p->selected |= COUNTRY_SELECT_ATTACK; gui_country_select(p->id); country_origen = p->id; textmsg(M_INF,_("Source country: '%s'. Now select the destination country"),countries_get_name(p->id)); } else { textmsg(M_ERR,_("Error, '%s' must have at least 2 armies"),countries_get_name(p->id)); return TEG_STATUS_UNEXPECTED; } } else { textmsg(M_ERR,_("Error, '%s' isn't one of your countries"),countries_get_name(p->id)); return TEG_STATUS_UNEXPECTED; } } else if( country_destino == -1 ) { if( country_origen == p->id ) { textmsg(M_INF,_("Source country is the same as the destination. Resetting the attack...")); attack_reset(); return TEG_STATUS_SUCCESS; } if(p->numjug != WHOAMI() ) { if( countries_eslimitrofe(country_origen, p->id) ) { p->selected &= ~COUNTRY_SELECT_ATTACK_ENTER; p->selected |= COUNTRY_SELECT_ATTACK; gui_country_select(p->id); country_destino = p->id; textmsg(M_INF,_("Destination country: '%s'. Attacking..."),countries_get_name(p->id)); attack_out(); } else { textmsg(M_ERR,_("Error, '%s' isn't frontier with '%s'"),countries_get_name(p->id),countries_get_name(country_origen)); attack_reset(); return TEG_STATUS_UNEXPECTED; } } else { textmsg(M_ERR,_("Error, you can't attack your own countries ('%s')"),countries_get_name(p->id)); attack_reset(); return TEG_STATUS_UNEXPECTED; } } else { attack_reset(); textmsg(M_ERR,_("Error, unexpected error in attack_click(). Report this bug!")); return TEG_STATUS_UNEXPECTED; } return TEG_STATUS_SUCCESS; }
TEG_STATUS attack_pre_reset() { if( attack_check() != TEG_STATUS_SUCCESS ) return TEG_STATUS_ERROR; else { attack_reset(); return TEG_STATUS_SUCCESS; } }
TEG_STATUS attack_init() { if( attack_check() != TEG_STATUS_SUCCESS ) return TEG_STATUS_UNEXPECTED; attack_backup(); attack_reset(); return TEG_STATUS_SUCCESS; }
/* Sends to server the attack message after restoring the last attack. Used when CTRL+R is pressed to reattack. */ TEG_STATUS attackre_out() { attack_restore(); TEG_STATUS ret; ret = attack_out(); // Reset attack information to fix bug [573300]: "error in ataque_click()". If the user clicks // on another country and both src_country and dest_country are already set, ataque_click // gets confused. So reset it, we can restore it if CTRL+R is pressed again. attack_reset(); return ret; }
/* src is attacking dst */ TEG_STATUS clitok_attack( char *str) { int src,dst; PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; PCPLAYER pJsrc, pJdst; p.igualador = &igualador; p.separador = &separador; p.data = str; if( strlen(str)==0 ) goto error; if( parser_call( &p ) && p.hay_otro ) { src = atoi( p.token ); } else goto error; if( parser_call( &p ) && !p.hay_otro ) { dst = atoi( p.token ); } else goto error; /* countries are allowed to be -1 (unknown in fog of war) */ if( src<-1 || src>=COUNTRIES_CANT || dst<-1 || dst>=COUNTRIES_CANT ) goto error; pJsrc = NULL; if( src >=0 ) player_whois( g_countries[src].numjug, &pJsrc ); pJdst = NULL; if( dst >=0 ) player_whois( g_countries[dst].numjug, &pJdst ); if( src >= 0 && g_countries[src].numjug == WHOAMI() ) { attack_reset(); } else { attack_show( src, dst ); } if( pJsrc && pJdst ) textmsg(M_INF,_("%s(%s) is attacking %s(%s)"), countries_get_name(src), _(g_colores[pJsrc->color]) ,countries_get_name(dst), _(g_colores[pJdst->color]) ); else textmsg(M_INF,_("%s is attacking %s"),countries_get_name(src), countries_get_name(dst) ); return TEG_STATUS_SUCCESS; error: textmsg(M_ERR,"Error in clitok_attack()"); return TEG_STATUS_ERROR; }
/* tells the server that my turn is over */ TEG_STATUS out_endturn() { PLAYER_STATUS e; e = ESTADO_GET(); if( e > PLAYER_STATUS_TURNOSTART && e < PLAYER_STATUS_TURNOEND ) { attack_reset(); reagrupe_reset(); ESTADO_SET( PLAYER_STATUS_IDLE ); net_printf(g_game.fd,TOKEN_TURNO"\n"); } else { textmsg( M_ERR,_("Error, it's not your turn.")); return TEG_STATUS_ERROR; } return TEG_STATUS_SUCCESS; }