Files
WT-Offline/native/wto-nav/wto_nav_protocol.h
T

50 lines
2.3 KiB
C

/*
* The "wtoNav" request protocol of the ground AI script, shared by the game (wto-net
* local_mp_nav.c) and the AI simulator (native/wto-ai-sim): the script fills a block of string
* values with `op` and its arguments, the host answers by writing ints and strings back into it.
* Coordinates in replies are centimetres. The host keeps the ops that depend on where the battle's
* pack comes from (prefetch, load_map, unload_map); everything that only needs the loaded pack is
* answered here.
*
* op=pump now (script seconds), budgetUs -> pending
* op=path_request slot, tier, filter (0 tracked, 1 wheeled), group (team, 0 none), snap,
* goalSnap, sx..sz, gx..gz -> ticket
* op=path_result slot, ticket -> status=pending|full|partial|no_start|no_goal|failed|stale,
* count, lenCm, truncated, goalMoved, p<i>x/p<i>y/p<i>z
* op=probe tier, filter, snap, wallR, px..pz -> onMesh, offCm, wallCm, area, flags,
* nx/ny/nz
* op=raycast tier, filter, snap, sx..sz, gx..gz -> clear=1|0|-1, hitPm, hx/hy/hz
* op=nearest tier, filter, radius, px..pz -> found, x/y/z
* op=dynamic px..pz, radius, mul, until (script seconds) -> count
* op=get_stats -> loaded, queries, failures, avgUs, maxUs, maxFrames, pumpMaxUs, pending,
* dynamic, meshQueries, traffic, cornersMoved
*
* load_map carries the per-class costs t_<area>, w_<area> and the search tuning trafficPerPath,
* trafficMaxMul, trafficHoldSec, cornerOffset; wto_nav_protocol_setup applies them.
*/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Access to one request block. get_str returns "" for a value the block does not have. */
typedef struct WtoNavBlock {
void *blk;
const char *(*get_str)(const void *blk, const char *name);
void (*set_str)(void *blk, const char *name, const char *value);
void (*set_int)(void *blk, const char *name, int32_t value);
} WtoNavBlock;
/* Hands the costs and search tuning of a load_map request to the engine, before it loads. */
void wto_nav_protocol_setup(const WtoNavBlock *b);
/* Answers `op` when it is one of the queries above; returns 0 for any other op. */
int wto_nav_protocol_query(const WtoNavBlock *b, const char *op);
#ifdef __cplusplus
}
#endif