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 #731235 ยป 0064-tex-update-world-object-instance-by-unit-moves.patch

Marko Lindqvist, 2018-02-06 10:20 PM

View differences:

ai/classic/classicai.c
ai->funcs.unit_turn_end = cai_unit_turn_end;
ai->funcs.unit_move = cai_unit_move_or_attack;
/* ai->funcs.unit_move_seen = NULL; */
ai->funcs.unit_task = cai_unit_new_adv_task;
ai->funcs.unit_save = cai_unit_save;
ai/tex/texai.c
ai->funcs.unit_turn_end = texwai_unit_turn_end;
ai->funcs.unit_move = texwai_unit_move_or_attack;
ai->funcs.unit_move_seen = texai_unit_move_seen;
ai->funcs.unit_task = texwai_unit_new_adv_task;
ai->funcs.unit_save = texwai_unit_save;
ai/tex/texaimsg.h
#define SPECENUM_VALUE8NAME "UnitCreated"
#define SPECENUM_VALUE9 TEXAI_MSG_UNIT_DESTROYED
#define SPECENUM_VALUE9NAME "UnitDestroyed"
#define SPECENUM_VALUE10 TEXAI_MSG_UNIT_MOVED
#define SPECENUM_VALUE10NAME "UnitMoved"
#include "specenum_gen.h"
#define SPECENUM_NAME texaireqtype
ai/tex/texaiplayer.c
case TEXAI_MSG_TILE_INFO:
texai_tile_info_recv(msg->data);
break;
case TEXAI_MSG_UNIT_MOVED:
texai_unit_moved_recv(msg->data);
break;
case TEXAI_MSG_UNIT_CREATED:
texai_unit_info_recv(msg->data, msg->type);
break;
ai/tex/texaiworld.c
int type;
};
struct texai_unit_move_msg
{
int id;
int tindex;
};
/**********************************************************************//**
Initialize world object for texai
**************************************************************************/
......
idex_unregister_unit(&texai_world, punit);
unit_virtual_destroy(punit);
}
/**********************************************************************//**
Unit has moved in the main map.
**************************************************************************/
void texai_unit_move_seen(struct unit *punit)
{
if (texai_thread_running()) {
struct texai_unit_move_msg *info = fc_malloc(sizeof(struct texai_unit_move_msg));
info->id = punit->id;
info->tindex = tile_index(unit_tile(punit));
texai_send_msg(TEXAI_MSG_UNIT_MOVED, NULL, info);
}
}
/**********************************************************************//**
Receive unit move to the thread.
**************************************************************************/
void texai_unit_moved_recv(void *data)
{
struct texai_unit_move_msg *info = (struct texai_unit_move_msg *)data;
struct unit *punit = idex_lookup_unit(&texai_world, info->id);
struct tile *ptile = index_to_tile(&(texai_world.map), info->tindex);
unit_list_remove(punit->tile->units, punit);
unit_list_prepend(ptile->units, punit);
unit_tile_set(punit, ptile);
}
ai/tex/texaiworld.h
void texai_unit_info_recv(void *data, enum texaimsgtype msgtype);
void texai_unit_destroyed(struct unit *punit);
void texai_unit_destruction_recv(void *data);
void texai_unit_move_seen(struct unit *punit);
void texai_unit_moved_recv(void *data);
#endif /* FC__TEXAIWORLD_H */
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-2017.Sep.26"
#define FC_AI_MOD_CAPSTR "+Freeciv-3.1-ai-module-2018.Feb.06"
/* Timers for all AI activities. Define it to get statistics about the AI. */
#ifdef FREECIV_DEBUG
......
void (*unit_move)(struct unit *punit, struct tile *ptile,
struct pf_path *path, int step);
/* Called for all AI types when ever unit has moved. */
void (*unit_move_seen)(struct unit *punit);
/* Called for unit owner AI type when new advisor task is set for unit. */
void (*unit_task)(struct unit *punit, enum adv_unit_task task,
struct tile *ptile);
doc/README.AI_modules
- Added 'tile_info', called when tile has changed
- 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
New in Freeciv 3.0:
server/unittools.c
conn_list_do_unbuffer(game.est_connections);
if (unit_lives) {
CALL_FUNC_EACH_AI(unit_move_seen, punit);
}
return unit_lives;
}
    (1-1/1)