/* give the 'token fichas' to the next player */ TEG_STATUS fichas_next( void ) { turno_2nextplayer( &g_game.turno ); if( turno_is_round_complete() ) { /* ya di la vuelta */ g_game.turno->estado = PLAYER_STATUS_FICHAS2; netall_printf( TOKEN_FICHAS2"=%d,%d\n",g_game.turno->numjug,g_game.fichas2); } else { /* paso el estado fichas al siguiente */ g_game.turno->estado = PLAYER_STATUS_FICHAS; netall_printf( TOKEN_FICHAS"=%d,%d\n",g_game.turno->numjug,g_game.fichas); } return TEG_STATUS_SUCCESS; }
/* give the 'token fichas 2' to the next player */ TEG_STATUS fichas2_next( void ) { turno_2nextplayer( &g_game.turno ); if( turno_is_round_complete() ) { /* ya di la vuelta, enconces a empezar a jugar */ g_game.turno->estado = PLAYER_STATUS_ATAQUE; netall_printf( TOKEN_TURNO"=%d\n",g_game.turno->numjug); } else { /* paso el estado fichas2 al siguiente */ g_game.turno->estado = PLAYER_STATUS_FICHAS2; netall_printf( TOKEN_FICHAS2"=%d,%d\n",g_game.turno->numjug,g_game.fichas2); } return TEG_STATUS_SUCCESS; }
/* Puts the player in Game Over state */ TEG_STATUS token_surrender( int fd, char *unused ) { PSPLAYER pJ; PLAY_DEBUG("token_surrender\n"); if( player_whoisfd( fd, &pJ ) != TEG_STATUS_SUCCESS ) goto error; if( !pJ->is_player ) goto error; if( pJ->estado < PLAYER_STATUS_HABILITADO ) goto error; con_text_out(M_INF,_("Player %s(%d) abandoned the game\n"),pJ->name,pJ->numjug); netall_printf("%s=%d\n", TOKEN_SURRENDER, pJ->numjug ); player_del_soft( pJ ); return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_SURRENDER"\n"); return TEG_STATUS_PARSEERROR; }
/* Sends the player the total number of armies he must place, and the continents he has conquered */ TEG_STATUS aux_token_fichasc( PSPLAYER pJ ) { unsigned long conts=0; int armies; int x_canje=0; assert( pJ ); if( pJ->fichasc_armies ) { conts = pJ->fichasc_conts; armies = pJ->fichasc_armies; } else { if( player_listar_conts( pJ, &conts ) != TEG_STATUS_SUCCESS ) return TEG_STATUS_UNEXPECTED; armies = player_fichasc_cant( pJ ); pJ->fichasc_conts = conts; pJ->fichasc_armies = armies; } if( pJ->hizo_canje ) x_canje = cuantos_x_canje( pJ->tot_exchanges ); pJ->estado = PLAYER_STATUS_FICHASC; netall_printf( TOKEN_FICHASC"=%d,%d,%d\n",pJ->numjug,conts,armies + x_canje ); return TEG_STATUS_SUCCESS; }
/* Ask for a card after the attack */ STATIC TEG_STATUS token_card( int fd, char *str ) { PSPLAYER pJ; PCOUNTRY pP; PLAY_DEBUG("token_card()\n"); /* Veo si puede sacar una tarjeta... */ if( player_whoisfd( fd, &pJ ) != TEG_STATUS_SUCCESS ) goto error; if( pJ->estado < PLAYER_STATUS_TURNOSTART || pJ->estado >= PLAYER_STATUS_TARJETA) goto error; // player may not have more than TEG_MAX_TARJETAS cards if( pJ->tot_cards >= TEG_MAX_TARJETAS ) goto error; // must have conquered a country to get a card if( pJ->turno_conq < 1 ) goto error; // after the 3rd exchange, the player must have conquered two countries if( pJ->tot_exchanges > 3 && pJ->turno_conq < 2 ) goto error; /* Puede sacar tarjeta */ pJ->tot_cards++; pP = get_random_country( tarjeta_es_libre ); pJ->estado = PLAYER_STATUS_TARJETA; tarjeta_sacar( &pP->tarjeta, pJ->numjug ); /* * Me fijo si el player es due�o del pa�s que dice la tarjeta. Si es as� * le agrego 2 fichas automaticamente como dice el reglamento. * Check if the card that the player gets is for a country that this player * owns. If yes, automatically place two armies according to the rules. */ if( pP->numjug == pJ->numjug ) { pP->ejercitos += 2; pJ->tot_armies += 2; tarjeta_usar( &pP->tarjeta ); if( ! g_game.fog_of_war ) netall_printf( "%s=%d,%d,%d\n", TOKEN_COUNTRY,pP->id,pP->numjug,pP->ejercitos); else fow_netall_printf( pP->id, "%s=%d,%d,%d\n", TOKEN_COUNTRY,pP->id,pP->numjug,pP->ejercitos); } net_printf(fd,"%s=%d,%d\n", TOKEN_TARJETA, pP->id,pP->tarjeta.usada); return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_TARJETA"\n"); return TEG_STATUS_ERROR; }
/* To exchange cards for armies */ STATIC TEG_STATUS token_canje( int fd, char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; PSPLAYER pJ; int t1,t2,t3; int canj_ejer; PLAY_DEBUG("token_canje()\n"); if( player_whoisfd( fd, &pJ ) != TEG_STATUS_SUCCESS ) goto error; if( pJ->estado != PLAYER_STATUS_FICHASC ) goto error; p.igualador = &igualador; p.separador = &separador; p.data = str; if( parser_call( &p ) && p.hay_otro ) { t1 = atoi( p.token ); } else goto error; if( parser_call( &p ) && p.hay_otro ) { t2 = atoi( p.token ); } else goto error; if( parser_call( &p ) && !p.hay_otro ) { t3 = atoi( p.token ); } else goto error; /* se puede hacer el canje ? */ if( !tarjeta_puedocanje( pJ->numjug, t1, t2, t3 ) ) goto error; pJ->estado = PLAYER_STATUS_CANJE; pJ->hizo_canje = TRUE; pJ->tot_exchanges++; pJ->tot_cards -= 3; canj_ejer = cuantos_x_canje( pJ->tot_exchanges ); /* quitarle las tarjetas al player */ tarjeta_poner( &g_countries[t1].tarjeta ); tarjeta_poner( &g_countries[t2].tarjeta ); tarjeta_poner( &g_countries[t3].tarjeta ); netall_printf("%s=%d,%d,%d,%d,%d\n", TOKEN_CANJE, pJ->numjug,canj_ejer,t1,t2,t3); return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_CANJE"\n"); return TEG_STATUS_PARSEERROR; }
/* Sends all the player a message. An observer may use this function */ STATIC TEG_STATUS token_message( int fd, char *msg ) { PSPLAYER j; PLAY_DEBUG("token_message()\n"); if( player_whoisfd(fd, &j )!=TEG_STATUS_SUCCESS || strlen(msg)==0 ) goto error; strip_invalid_msg(msg); if( j->is_player ) netall_printf("%s=%s,%d,\"%s\"\n", TOKEN_MESSAGE, j->name,j->numjug,msg); else netall_printf("%s=observer-%s,%d,\"%s\"\n", TOKEN_MESSAGE, j->name,j->numjug,msg); return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_MESSAGE"\n"); return TEG_STATUS_PARSEERROR; }
/* To start the game */ TEG_STATUS token_start( int fd ) { char strout[PROT_MAX_LEN + PLAYERNAME_MAX_LEN * TEG_MAX_PLAYERS + 200]; PSPLAYER pJ; PLAY_DEBUG("token_start()\n"); if( JUEGO_EMPEZADO || g_game.players < 2 ) goto error; if( g_server.with_console && fd != CONSOLE_FD) { if( !SPLAYER_HABILITADO_P(fd,&pJ) || !pJ->is_player ) goto error; } JUEGO_EN_EMPEZAR; g_game.playing = g_game.players; con_text_out(M_INF,_("Starting game number: %d with seed: %u\n"),g_game.gamenumber,g_game.seed); player_all_set_status ( PLAYER_STATUS_START ); countries_repartir(); if(turno_init() != TEG_STATUS_SUCCESS ) { con_text_out(M_ERR,_("Error, can't initialize a new turn\n")); goto error; } JUEGO_EN_FICHAS; g_game.turno->estado = PLAYER_STATUS_FICHAS; aux_token_stasta(strout, sizeof(strout) -1 ); netall_printf( "%s=%s;%s=%d,%d;%s=%d,%d,%d,%d;%s=%d,%d\n" ,TOKEN_START ,strout /* available players */ ,TOKEN_NEW_ROUND ,g_game.turno->numjug /* who starts the new turn */ ,g_game.round_number /* the round number */ ,TOKEN_MODALIDAD ,g_game.mission /* play with missions ? */ ,g_game.cmission /* play with common mission */ ,g_game.fog_of_war /* play with fog of war */ ,g_game.reglas /* which rules ? */ ,TOKEN_FICHAS ,g_game.turno->numjug, /* who starts ? */ g_game.fichas ); /* how many armies to place */ return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_START"\n"); return TEG_STATUS_PARSEERROR; }
/* Place 2 armies in the card's country. The player must own the country */ STATIC TEG_STATUS token_ejer2( int fd, char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; int country; PSPLAYER j; PLAY_DEBUG("token_ejer2()\n"); if( strlen(str)==0) goto error; if( player_whoisfd( fd, &j ) != TEG_STATUS_SUCCESS ) goto error; if( j->estado != PLAYER_STATUS_TARJETA ) goto error; p.igualador = &igualador; p.separador = &separador; p.data = str; if( parser_call( &p ) && !p.hay_otro ) { country = atoi( p.token ); } else goto error; if( country >= COUNTRIES_CANT || country < 0 ) { goto error; } if( tarjeta_es_usada( &g_countries[ country ].tarjeta )) goto error; if( g_countries[ country ].numjug == j->numjug && g_countries[ country ].tarjeta.numjug == j->numjug ) { g_countries[ country ].ejercitos += 2; j->tot_armies += 2; tarjeta_usar( &g_countries[ country ].tarjeta ); if( ! g_game.fog_of_war ) netall_printf("%s=%d,%d,%d\n", TOKEN_COUNTRY ,country ,g_countries[ country ].numjug ,g_countries[ country ].ejercitos); else fow_netall_printf( country, "%s=%d,%d,%d\n", TOKEN_COUNTRY ,country ,g_countries[ country ].numjug ,g_countries[ country ].ejercitos); } return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_EJER2"\n"); return TEG_STATUS_PARSEERROR; }
/* give the 'token fichas c' to the next player */ TEG_STATUS fichasc_next( void ) { turno_2nextplayer( &g_game.turno ); if( turno_is_round_complete() ) { /* ya di la vuelta */ g_game.turno->estado = PLAYER_STATUS_ATAQUE; netall_printf( TOKEN_TURNO"=%d\n",g_game.turno->numjug); } else { aux_token_fichasc( g_game.turno ); } return TEG_STATUS_SUCCESS; }
/* Assigns the player a color */ STATIC TEG_STATUS token_color( int fd, char *str ) { int color; int a; PSPLAYER pJ; PLAY_DEBUG("token_color()"); if( player_whoisfd( fd, &pJ ) != TEG_STATUS_SUCCESS ) { goto error; } if(strlen(str)==0) goto error; if( pJ->estado != PLAYER_STATUS_CONNECTED ) goto error; if( pJ->is_player == FALSE ) goto error; a = atoi( str ); if (a < 0 || a >= TEG_MAX_PLAYERS ) goto error; color = a; if ( color_libre( &color ) == FALSE ) goto error; pJ->estado = PLAYER_STATUS_HABILITADO; pJ->color = color; con_text_out(M_INF,_("Player %s(%d) has color %s\n"),pJ->name,pJ->numjug,_(g_colores[color])); netall_printf( "%s=%s,%d,%d\n", TOKEN_NEWPLAYER, pJ->name, pJ->numjug, pJ->color ); return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_COLOR"\n"); return TEG_STATUS_PARSEERROR; }
/* ends the game */ void game_end( PSPLAYER winner ) { char strout[PROT_MAX_LEN + PLAYERNAME_MAX_LEN * TEG_MAX_PLAYERS + 200]; PLIST_ENTRY l = g_list_player.Flink; PSPLAYER pJ; /* add points to the winner */ if( winner && g_game.round_number > 0 ) { int points = 350 / g_game.round_number; winner->player_stats.score += points; } /* update scores */ player_map( player_insert_scores ); if( aux_token_stasta(strout, sizeof(strout) -1 ) == TEG_STATUS_SUCCESS ) { /* send the last status to all the players */ while( !IsListEmpty( &g_list_player ) && (l != &g_list_player) ) { pJ = (PSPLAYER) l; if( pJ->is_player && pJ->fd != 1) net_printf(pJ->fd,TOKEN_STATUS"=%s\n",strout); l = LIST_NEXT(l); } } /* delete disconn players */ player_map( player_delete_discon ); /* send who is the winner */ if( winner ) netall_printf( TOKEN_WINNER"=%d,%d\n",winner->numjug,winner->mission ); game_new(); }
/* sends a player the type of game it is being played */ TEG_STATUS token_typeofgame( int fd, char *str ) { PSPLAYER pJ; PLAY_DEBUG("token_typeofgame()\n"); if( JUEGO_EMPEZADO ) goto error; if( !SPLAYER_HABILITADO_P(fd,&pJ) || !pJ->is_player ) goto error; netall_printf( "%s=%d,%d,%d,%d;\n" ,TOKEN_MODALIDAD ,g_game.mission /* play with missions ? */ ,g_game.cmission /* play with common mission */ ,g_game.fog_of_war /* play with fog of war */ ,g_game.reglas /* which rules ? */ ); return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_MODALIDAD"\n"); return TEG_STATUS_PARSEERROR; }
/* Gives turn to the next player */ TEG_STATUS turno_next( void ) { assert(g_game.turno); /* give turn to the next one */ if( turno_2nextplayer( &g_game.turno ) == TEG_STATUS_SUCCESS ) { /* the one who has the turn is the one that started ? */ if( turno_is_round_complete() ) { turno_initialize_new_round(); aux_token_fichasc( g_game.turno ); } else { g_game.turno->estado = PLAYER_STATUS_ATAQUE; netall_printf( TOKEN_TURNO"=%d\n",g_game.turno->numjug); } return TEG_STATUS_SUCCESS; } return TEG_STATUS_ERROR; }
/* Place armies in the conquered country */ STATIC TEG_STATUS token_tropas( int fd, char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; int src,dst,cant; PSPLAYER pJ; PLAY_DEBUG("token_tropas()\n"); if( !SPLAYER_TROPAS_P(fd,&pJ) || strlen(str)==0 ) goto error; p.igualador = &igualador; p.separador = &separador; p.data = str; 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; if( parser_call( &p ) && !p.hay_otro ) { cant = atoi( p.token ); } else goto error; if( src >= COUNTRIES_CANT || src < 0 || dst >= COUNTRIES_CANT || dst < 0) { goto error; } if( src != pJ->country_src || dst != pJ->country_dst ) goto error; if( cant > g_countries[src].ejercitos-1 || cant > 3) goto error; if( cant > 0 ) { g_countries[src].ejercitos -= cant; g_countries[dst].ejercitos += cant; pJ->estado=PLAYER_STATUS_ATAQUE; pJ->country_src = pJ->country_dst = -1; if( ! g_game.fog_of_war ) netall_printf( "%s=%d,%d,%d;%s=%d,%d,%d\n", TOKEN_COUNTRY, src,g_countries[src].numjug,g_countries[src].ejercitos, TOKEN_COUNTRY, dst,g_countries[dst].numjug,g_countries[dst].ejercitos ); else { fow_netall_printf( src, "%s=%d,%d,%d\n", TOKEN_COUNTRY, src,g_countries[src].numjug,g_countries[src].ejercitos ); fow_netall_printf( dst, "%s=%d,%d,%d\n", TOKEN_COUNTRY, dst,g_countries[dst].numjug,g_countries[dst].ejercitos ); } } return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_TROPAS"\n"); return TEG_STATUS_PARSEERROR; }
/* A player is attacking from src to dst */ STATIC TEG_STATUS token_attack( int fd, char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; int src,dst,src_lost,dst_lost; char d_src[3],d_dst[3]; PSPLAYER pJ_src, pJ_dst; int conq = 0; int tropas = 0; char buffer[4096]; PLAY_DEBUG("token_attack()\n"); if( strlen(str)==0) goto error; if( !SPLAYER_ATAQUE_P(fd,&pJ_src)) { if( SPLAYER_TROPAS_P(fd,&pJ_src)) { pJ_src->estado=PLAYER_STATUS_ATAQUE; pJ_src->country_src = pJ_src->country_dst = -1; } else goto error; } p.igualador = &igualador; p.separador = &separador; p.data = str; 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; if( src >= COUNTRIES_CANT || src < 0 || dst >= COUNTRIES_CANT || dst < 0) { goto error; } if( pJ_src->numjug != g_countries[src].numjug || pJ_src->numjug == g_countries[dst].numjug ) { goto error; } if( g_countries[src].ejercitos < 2 || !countries_eslimitrofe( src, dst) ) { goto error; } if( player_whois( g_countries[dst].numjug, &pJ_dst ) != TEG_STATUS_SUCCESS ){ goto error; } if( pactos_attack( src, dst ) != TEG_STATUS_SUCCESS ) goto error; /* aviso a todos que hay un attack */ if( ! g_game.fog_of_war ) netall_printf( "%s=%d,%d\n",TOKEN_ATAQUE,src,dst ); else { fow_2_netall_printf( src, dst, "%s=%s,%s\n",TOKEN_ATAQUE,"%d","%d" ); } /* so far, attack... */ aux_token_attack( g_countries[src].ejercitos, g_countries[dst].ejercitos, &src_lost, &dst_lost, d_src, d_dst ); g_countries[src].ejercitos -= src_lost; g_countries[dst].ejercitos -= dst_lost; pJ_src->tot_armies -= src_lost; pJ_dst->tot_armies -= dst_lost; /* updated statistics */ pJ_src->player_stats.armies_killed += dst_lost; pJ_dst->player_stats.armies_killed += src_lost; pJ_dst->player_stats.armies_lost += dst_lost; pJ_src->player_stats.armies_lost += src_lost; /* conquisto el country | country was conquered */ if( g_countries[dst].ejercitos == 0) { PLIST_ENTRY l; conq = 1; pJ_src->turno_conq++; pJ_src->tot_countries++; g_countries[dst].numjug = pJ_src->numjug; g_countries[dst].ejercitos++; /* se pasa automaticamente */ g_countries[src].ejercitos--; /* un ejercito */ tropas = g_countries[src].ejercitos - 1; /* cantidad que se pueden pasar */ if( tropas > 2 ) /* En verdad son 3, pero ya se le paso 1 */ tropas =2; pJ_src->estado = PLAYER_STATUS_TROPAS; pJ_src->country_src = src; pJ_src->country_dst = dst; pJ_dst->tot_countries--; l= RemoveHeadList( g_countries[dst].next.Blink ); InsertTailList( &pJ_src->countries, l); /* updated statistics */ pJ_src->player_stats.countries_won ++; pJ_dst->player_stats.countries_lost ++; } /* update the scores */ stats_score( &pJ_src->player_stats ); stats_score( &pJ_dst->player_stats ); /* tell everybody the result of the attack */ memset( buffer, 0, sizeof(buffer) ); if( ! g_game.fog_of_war ) { netall_printf( "%s=%d,%d,%d,%d,%d,%d,%d,%d\n", TOKEN_DADOS, src,d_src[0],d_src[1],d_src[2], dst,d_dst[0],d_dst[1],d_dst[2] ); } else { fow_2_netall_printf( src, dst, "%s=%s,%d,%d,%d,%s,%d,%d,%d\n" , TOKEN_DADOS , "%d",d_src[0],d_src[1],d_src[2] , "%d",d_dst[0],d_dst[1],d_dst[2] ); } if( ! g_game.fog_of_war ) { netall_printf( "%s=%d,%d,%d;%s=%d,%d,%d\n", TOKEN_COUNTRY, src, g_countries[src].numjug, g_countries[src].ejercitos, TOKEN_COUNTRY, dst, g_countries[dst].numjug, g_countries[dst].ejercitos ); } else { fow_netall_printf( src, "%s=%d,%d,%d\n", TOKEN_COUNTRY, src, g_countries[src].numjug, g_countries[src].ejercitos ); fow_netall_printf( dst, "%s=%d,%d,%d\n", TOKEN_COUNTRY, dst, g_countries[dst].numjug, g_countries[dst].ejercitos ); } if( conq == 1 ) { /* Did 'dst' player lose the game ? */ if( player_is_lost( pJ_dst ) ) { con_text_out(M_INF,_("Player %s(%d) lost the game\n"),pJ_dst->name,pJ_dst->numjug); netall_printf( "%s=%d\n",TOKEN_LOST, pJ_dst->numjug ); player_poner_perdio(pJ_dst); } /* Did 'src' player win the game ? */ if( mission_chequear( pJ_src ) == TEG_STATUS_GAMEOVER || game_is_finished() ) { #ifdef WITH_GGZ ggz_server_gameover(pJ_src->fd); #endif con_text_out(M_INF,_("Player %s(%d) is the winner! Game Over\n"),pJ_src->name,pJ_src->numjug); pJ_src->estado = PLAYER_STATUS_GAMEOVER; game_end( pJ_src ); return TEG_STATUS_SUCCESS; } net_printf(fd,"%s=%d,%d,%d\n", TOKEN_TROPAS, src,dst,tropas); /* in FOW show the boundaries countries */ if( g_game.fog_of_war ) { char buffer[2048]; memset( buffer, 0, sizeof(buffer) ); if( fow_fill_with_boundaries( dst, buffer, sizeof(buffer) ) == TEG_STATUS_SUCCESS ) net_printf( fd, "%s\n", buffer ); } } return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_ATAQUE"\n"); return TEG_STATUS_PARSEERROR; }
/* Player is regrouping its armies */ STATIC TEG_STATUS token_regroup( int fd, char *str ) { PARSER p; DELIM igualador={ ':', ':', ':' }; DELIM separador={ ',', ',', ',' }; int src,dst,cant; int ejer_disp; PSPLAYER pJ; PLAY_DEBUG("token_regroup()\n"); if( strlen(str)==0) goto error; if( player_whoisfd( fd, &pJ ) != TEG_STATUS_SUCCESS ) goto error; if( pJ->estado < PLAYER_STATUS_TURNOSTART || pJ->estado > PLAYER_STATUS_REAGRUPE) goto error; p.igualador = &igualador; p.separador = &separador; p.data = str; 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; if( parser_call( &p ) && !p.hay_otro ) { cant = atoi( p.token ); } else goto error; if( src >= COUNTRIES_CANT || src < 0 || dst >= COUNTRIES_CANT || dst < 0 || cant <= 0) { goto error; } if( g_countries[src].numjug != pJ->numjug || g_countries[dst].numjug != pJ->numjug ) { goto error; } if( !countries_eslimitrofe( src, dst )) goto error; ejer_disp = g_countries[src].ejercitos - g_countries[src].ejer_reagrupe - 1; if( cant > ejer_disp ) goto error; pJ->estado = PLAYER_STATUS_REAGRUPE; g_countries[dst].ejercitos += cant; g_countries[dst].ejer_reagrupe += cant; g_countries[src].ejercitos -= cant; if( ! g_game.fog_of_war ) { netall_printf("%s=%d,%d,%d;%s=%d,%d,%d\n", TOKEN_COUNTRY, src,g_countries[src].numjug,g_countries[src].ejercitos, TOKEN_COUNTRY, dst,g_countries[dst].numjug,g_countries[dst].ejercitos ); } else { fow_netall_printf( src, "%s=%d,%d,%d\n", TOKEN_COUNTRY, src,g_countries[src].numjug,g_countries[src].ejercitos ); fow_netall_printf( dst, "%s=%d,%d,%d\n", TOKEN_COUNTRY, dst,g_countries[dst].numjug,g_countries[dst].ejercitos ); } return TEG_STATUS_SUCCESS; error: net_print(fd,TOKEN_ERROR"="TOKEN_REAGRUPE"\n"); return TEG_STATUS_PARSEERROR; }