Crossfire Client, Trunk
|
#include <stdint.h>
#include "client.h"
#include "external.h"
#include "script.h"
#include "mapdata.h"
Go to the source code of this file.
Functions | |
void | clear_fire () |
void | clear_run () |
void | client_send_apply (int tag) |
void | client_send_examine (int tag) |
void | client_send_move (int loc, int tag, int nrof) |
void | command_take (const char *command, const char *cpnext) |
int | command_to_direction (const char *dir) |
void | CompleteCmd (unsigned char *data, int len) |
const char * | dir_to_command (int dir) |
void | fire_dir (int dir) |
void | look_at (int x, int y) |
void | new_player (long tag, char *name, long weight, long face) |
void | predict_scroll (int dir) |
void | run_dir (int dir) |
int | send_command (const char *command, int repeat, int must_send) |
static bool | starts_with (const char *prefix, const char *str) |
void | stop_fire () |
void | stop_run () |
void | walk_dir (int dir) |
Variables | |
static int | dfire =-1 |
const char *const | directions [] |
static int | drun =-1 |
bool | is_afk |
time_t | last_command_sent |
bool | profile_latency = false |
int64_t * | profile_time = NULL |
Handles various player related functions. This includes both things that operate on the player item, cpl structure, or various commands that the player issues.
Most of the handling of commands from the client to server (see commands.c for server->client) is handled here.
Most of the work for sending messages to the server is done here. Again, most of these appear self explanatory. Most send a bunch of commands like apply, examine, fire, run, etc. This looks like it was done by Mark to remove the old keypress stupidity I used.
Definition in file player.c.
void clear_fire | ( | ) |
Definition at line 115 of file player.c.
References dfire, SC_FIRERUN, and send_command().
Referenced by focusoutfunc(), map_button_event(), and parse_key_release().
void clear_run | ( | ) |
Definition at line 122 of file player.c.
References drun, SC_FIRERUN, and send_command().
Referenced by focusoutfunc(), and parse_key_release().
void client_send_apply | ( | int | tag | ) |
Definition at line 86 of file player.c.
References cs_print_string(), csocket, and ClientSocket::fd.
Referenced by list_item_action(), list_row_collapse(), ma_apply(), and script_process_cmd().
void client_send_examine | ( | int | tag | ) |
Definition at line 90 of file player.c.
References cs_print_string(), csocket, and ClientSocket::fd.
Referenced by list_item_action(), and ma_examine().
void client_send_move | ( | int | loc, |
int | tag, | ||
int | nrof | ||
) |
Request to move 'nrof' objects with 'tag' to 'loc'.
Definition at line 97 of file player.c.
References cs_print_string(), csocket, and ClientSocket::fd.
Referenced by list_item_drop(), and script_process_cmd().
void command_take | ( | const char * | command, |
const char * | cpnext | ||
) |
Definition at line 351 of file player.c.
References Player_Struct::container, Player_Struct::count, cpl, cs_print_string(), csocket, draw_ext_info(), ClientSocket::fd, item_struct::inv, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, Player_Struct::ob, send_command(), and item_struct::tag.
Referenced by do_take().
int command_to_direction | ( | const char * | dir | ) |
Definition at line 164 of file player.c.
References directions.
Referenced by send_command().
void CompleteCmd | ( | unsigned char * | data, |
int | len | ||
) |
Definition at line 319 of file player.c.
References ClientSocket::command_received, ClientSocket::command_sent, ClientSocket::command_time, csocket, ClientSocket::dir, drun, GetInt_String(), GetShort_String(), LOG(), LOG_ERROR, predict_scroll(), profile_latency, profile_time, and script_sync().
const char* dir_to_command | ( | int | dir | ) |
Definition at line 173 of file player.c.
References directions.
Referenced by walk_dir().
void fire_dir | ( | int | dir | ) |
Definition at line 129 of file player.c.
References Player_Struct::count, cpl, dfire, Player_Struct::input_state, MAX_BUF, Playing, SC_NORMAL, and send_command().
Referenced by map_button_event(), and parse_key().
void look_at | ( | int | x, |
int | y | ||
) |
Definition at line 82 of file player.c.
References cs_print_string(), csocket, and ClientSocket::fd.
Referenced by map_button_event().
void new_player | ( | long | tag, |
char * | name, | ||
long | weight, | ||
long | face | ||
) |
Initialize player object using information from the server.
Definition at line 54 of file player.c.
References copy_name, cpl, item_struct::d_name, item_struct::face, is_afk, keybindings_init(), last_command_sent, Spell_struct::next, item_struct::nrof, Player_Struct::ob, Player_Struct::spelldata, item_struct::tag, and item_struct::weight.
Referenced by PlayerCmd().
void predict_scroll | ( | int | dir | ) |
Change map drawing offset to provide local movement prediction based on player's movement commands to the server.
Definition at line 185 of file player.c.
References want_offset_x, and want_offset_y.
Referenced by CompleteCmd(), and send_command().
void run_dir | ( | int | dir | ) |
Definition at line 150 of file player.c.
References drun, MAX_BUF, SC_NORMAL, and send_command().
Referenced by parse_key(), and run_move_to().
int send_command | ( | const char * | command, |
int | repeat, | ||
int | must_send | ||
) |
Definition at line 235 of file player.c.
References clear_move_to(), COMMAND_MAX, ClientSocket::command_received, ClientSocket::command_sent, command_to_direction(), CONFIG_CWINDOW, CONFIG_ECHO, Player_Struct::count, cpl, cs_print_string(), ClientSocket::cs_version, csocket, ClientSocket::dir, draw_ext_info(), drun, ClientSocket::fd, Player_Struct::input_state, is_afk, last_command_sent, LOG(), LOG_ERROR, MAX_BUF, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_NOTICE, NDI_BLACK, predict_scroll(), profile_latency, profile_time, Reply_One, SC_MOVETO, script_monitor(), SockList_AddInt(), SockList_AddShort(), SockList_AddString(), SockList_Init(), SockList_Send(), starts_with(), and use_config.
Referenced by auto_afk(), clear_fire(), clear_run(), command_help(), command_take(), do_mapedit(), extended_command(), fire_dir(), new_menu_pickup(), on_auto_afk_response(), on_spell_cast_clicked(), on_spell_invoke_clicked(), run_dir(), script_process_cmd(), stop_run(), trigger_skill(), and walk_dir().
|
static |
Definition at line 222 of file player.c.
Referenced by send_command().
void stop_fire | ( | ) |
void stop_run | ( | ) |
Definition at line 145 of file player.c.
References drun, SC_FIRERUN, and send_command().
Referenced by keyfunc(), and run_move_to().
void walk_dir | ( | int | dir | ) |
Definition at line 177 of file player.c.
References dir_to_command(), SC_MOVETO, and send_command().
Referenced by run_move_to().
|
static |
Definition at line 106 of file player.c.
Referenced by clear_fire(), fire_dir(), and stop_fire().
const char *const directions |
256-length array to keep track of when commands were sent to the server Array for direction strings for each numeric direction.
Definition at line 41 of file player.c.
Referenced by command_to_direction(), dir_to_command(), and keybind_insert().
|
static |
Definition at line 106 of file player.c.
Referenced by clear_run(), CompleteCmd(), run_dir(), send_command(), and stop_run().
bool is_afk |
Best guess whether or not we are currently AFK or not.
Definition at line 46 of file player.c.
Referenced by client_tick(), new_player(), on_auto_afk_response(), and send_command().
time_t last_command_sent |
Time when last command was sent. Used to keep track of auto-AFK.
Definition at line 49 of file player.c.
Referenced by client_tick(), new_player(), and send_command().
bool profile_latency = false |
Definition at line 36 of file player.c.
Referenced by CompleteCmd(), and send_command().
int64_t* profile_time = NULL |
Definition at line 37 of file player.c.
Referenced by CompleteCmd(), and send_command().