mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r3306) -Fix: forgot sometimes to switch to the right current_player for AIs
This commit is contained in:
parent
531073bea0
commit
6884453b66
9
ai/ai.c
9
ai/ai.c
@ -390,10 +390,16 @@ void AI_StartNewAI(PlayerID player)
|
|||||||
if (_ai.gpmi) {
|
if (_ai.gpmi) {
|
||||||
char *library = NULL;
|
char *library = NULL;
|
||||||
char *params = NULL;
|
char *params = NULL;
|
||||||
|
int old_cp = _current_player;
|
||||||
|
|
||||||
|
/* Switch to new player, so we can execute stuff */
|
||||||
|
_current_player = player;
|
||||||
|
|
||||||
|
/* Get the library and param to load */
|
||||||
ttai_GetNextAIData(&library, ¶ms);
|
ttai_GetNextAIData(&library, ¶ms);
|
||||||
gpmi_error_stack_enable = 1;
|
gpmi_error_stack_enable = 1;
|
||||||
|
|
||||||
|
/* Load the module */
|
||||||
if (library != NULL) {
|
if (library != NULL) {
|
||||||
_ai_player[player].module = gpmi_mod_load(library, params);
|
_ai_player[player].module = gpmi_mod_load(library, params);
|
||||||
free(library);
|
free(library);
|
||||||
@ -401,6 +407,7 @@ void AI_StartNewAI(PlayerID player)
|
|||||||
if (params != NULL)
|
if (params != NULL)
|
||||||
free(params);
|
free(params);
|
||||||
|
|
||||||
|
/* Check for errors */
|
||||||
if (_ai_player[player].module == NULL) {
|
if (_ai_player[player].module == NULL) {
|
||||||
DEBUG(ai, 0)("[AI] Failed to load AI, aborting. GPMI error stack:");
|
DEBUG(ai, 0)("[AI] Failed to load AI, aborting. GPMI error stack:");
|
||||||
gpmi_err_stack_process_str(AI_PrintErrorStack);
|
gpmi_err_stack_process_str(AI_PrintErrorStack);
|
||||||
@ -408,6 +415,8 @@ void AI_StartNewAI(PlayerID player)
|
|||||||
}
|
}
|
||||||
gpmi_error_stack_enable = 0;
|
gpmi_error_stack_enable = 0;
|
||||||
|
|
||||||
|
/* Switch back to last player */
|
||||||
|
_current_player = old_cp;
|
||||||
}
|
}
|
||||||
#endif /* GPMI */
|
#endif /* GPMI */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user