Project

Profile

Help

HostedRedmine.com has moved to the Planio platform. All logins and passwords remained the same. All users will be able to login and use Redmine just as before. *Read more...*

Feature #803003 ยป 0007-Tex-Update-unit-type-on-tex-map.patch

Marko Lindqvist, 2019-02-16 11:54 AM

View differences:

ai/classic/classicai.c
/* ai->funcs.tile_info = NULL; */
/* ai->funcs.city_info = NULL; */
/* ai->funcs.unit_info = NULL; */
return TRUE;
}
ai/tex/texai.c
ai->funcs.tile_info = texai_tile_info;
ai->funcs.city_info = texai_city_changed;
ai->funcs.unit_info = texai_unit_changed;
return TRUE;
}
ai/tex/texaimsg.h
#define SPECENUM_VALUE8NAME "CityDestroyed"
#define SPECENUM_VALUE9 TEXAI_MSG_UNIT_CREATED
#define SPECENUM_VALUE9NAME "UnitCreated"
#define SPECENUM_VALUE10 TEXAI_MSG_UNIT_DESTROYED
#define SPECENUM_VALUE10NAME "UnitDestroyed"
#define SPECENUM_VALUE11 TEXAI_MSG_UNIT_MOVED
#define SPECENUM_VALUE11NAME "UnitMoved"
#define SPECENUM_VALUE10 TEXAI_MSG_UNIT_CHANGED
#define SPECENUM_VALUE10NAME "UnitChanged"
#define SPECENUM_VALUE11 TEXAI_MSG_UNIT_DESTROYED
#define SPECENUM_VALUE11NAME "UnitDestroyed"
#define SPECENUM_VALUE12 TEXAI_MSG_UNIT_MOVED
#define SPECENUM_VALUE12NAME "UnitMoved"
#include "specenum_gen.h"
#define SPECENUM_NAME texaireqtype
ai/tex/texaiplayer.c
texai_unit_moved_recv(msg->data);
break;
case TEXAI_MSG_UNIT_CREATED:
case TEXAI_MSG_UNIT_CHANGED:
texai_unit_info_recv(msg->data, msg->type);
break;
case TEXAI_MSG_UNIT_DESTROYED:
ai/tex/texaiworld.c
**************************************************************************/
static void texai_unit_update(struct unit *punit, enum texaireqtype msgtype)
{
struct texai_unit_info_msg *info
= fc_malloc(sizeof(struct texai_unit_info_msg));
if (texai_thread_running()) {
struct texai_unit_info_msg *info
= fc_malloc(sizeof(struct texai_unit_info_msg));
info->id = punit->id;
info->owner = player_number(unit_owner(punit));
info->tindex = tile_index(unit_tile(punit));
info->type = utype_number(unit_type_get(punit));
info->id = punit->id;
info->owner = player_number(unit_owner(punit));
info->tindex = tile_index(unit_tile(punit));
info->type = utype_number(unit_type_get(punit));
texai_send_msg(msgtype, NULL, info);
texai_send_msg(msgtype, NULL, info);
}
}
/**********************************************************************//**
......
**************************************************************************/
void texai_unit_created(struct unit *punit)
{
if (texai_thread_running()) {
texai_unit_update(punit, TEXAI_MSG_UNIT_CREATED);
}
texai_unit_update(punit, TEXAI_MSG_UNIT_CREATED);
}
/**********************************************************************//**
Unit (potentially) changed in main map.
**************************************************************************/
void texai_unit_changed(struct unit *punit)
{
texai_unit_update(punit, TEXAI_MSG_UNIT_CHANGED);
}
/**********************************************************************//**
......
idex_register_unit(&texai_world, punit);
unit_list_prepend(ptile->units, punit);
unit_list_prepend(plr_data->units, punit);
} else {
} else if (msgtype == TEXAI_MSG_UNIT_MOVED) {
struct tile *old_tile;
punit = idex_lookup_unit(&texai_world, info->id);
......
unit_list_remove(old_tile->units, punit);
unit_list_prepend(ptile->units, punit);
}
} else {
fc_assert(msgtype == TEXAI_MSG_UNIT_CHANGED);
punit = idex_lookup_unit(&texai_world, info->id);
punit->utype = type;
}
unit_tile_set(punit, ptile);
ai/tex/texaiworld.h
struct city *texai_map_city(int city_id);
void texai_unit_created(struct unit *punit);
void texai_unit_changed(struct unit *punit);
void texai_unit_info_recv(void *data, enum texaimsgtype msgtype);
void texai_unit_destroyed(struct unit *punit);
void texai_unit_destruction_recv(void *data);
common/ai.h
* structure below. When changing mandatory capability part, check that
* there's enough reserved_xx pointers in the end of the structure for
* taking to use without need to bump mandatory capability again. */
#define FC_AI_MOD_CAPSTR "+Freeciv-3.1-ai-module-2019.Feb.11"
#define FC_AI_MOD_CAPSTR "+Freeciv-3.1-ai-module-2019.Feb.16"
/* Timers for all AI activities. Define it to get statistics about the AI. */
#ifdef FREECIV_DEBUG
......
*/
void (*city_info)(struct city *pcity);
/* Called for every AI type when certain kind of unit change has taken place.
* Currently this gets called when:
* - unit updates & conversions
*/
void (*unit_info)(struct unit *punit);
/* These are here reserving space for future optional callbacks.
* This way we don't need to change the mandatory capability of the AI module
* interface when adding such callbacks, but existing modules just have these
doc/README.AI_modules
- Added 'tile_info', called when tile has changed
- Added 'city_info', called when city has changed (calls still happen for few
specific changes only)
- Added 'unit_info', called when unit has changed (calls still happen for few
specific changes only)
- Added 'map_alloc' and 'map_free', called when map tiles are allocated or freed
- Added 'map_ready', called when map has been generated or, in case of scenario, loaded
- Added 'unit_move_seen', called for all AI types when unit moves
server/unittools.c
unit_refresh_vision(punit);
CALL_PLR_AI_FUNC(unit_transformed, pplayer, punit, old_type);
CALL_FUNC_EACH_AI(unit_info, punit);
send_unit_info(NULL, punit);
conn_list_do_unbuffer(pplayer->connections);
    (1-1/1)