Go to the documentation of this file.
36 #define MAXITEMLEN 300
50 unsigned int flags = 0;
123 int flags, len, anim_speed;
150 len = strlen(item_n);
155 len = strlen(item_n);
158 strncpy(item_n+len+1, item_p, 127);
160 item_n[len+1+127] = 0;
161 len += strlen(item_n+1+len)+1;
177 if (anim_speed > 255)
195 int got_one = 0, start_look = 0, end_look = 0, objects_sent = 0;
199 if (!
pl->contr->socket->update_look) {
200 LOG(
llevDebug,
"esrv_draw_look called when update_look was not set\n");
203 pl->contr->socket->update_look = 0;
212 if (
pl->contr->transport)
230 if (
pl->contr->socket->look_position) {
231 int overhead = 1+(
pl->contr->transport != NULL);
232 int prev_len =
pl->contr->socket->num_look_objects-overhead-(
pl->contr->socket->look_position >
pl->contr->socket->num_look_objects-overhead);
237 snprintf(
buf,
sizeof(
buf),
"Click here to see previous group of items");
247 if (
pl->contr->transport) {
270 if (start_look++ <
pl->contr->socket->look_position)
274 if (objects_sent >=
pl->contr->socket->num_look_objects) {
283 snprintf(
buf,
sizeof(
buf),
"Click here to see next group of items");
317 int got_one = 0, start_look = 0, end_look = 0, objects_sent = 0;
320 int prev_len =
pl->contr->socket->num_look_objects - 2 - (((
pl->contr->socket->container_position >
pl->contr->socket->num_look_objects - 1)) ? 1 : 0);
331 if (
pl !=
op &&
pl->contr->socket->container_position) {
336 snprintf(
buf,
sizeof(
buf),
"Click here to see previous group of items");
351 if (start_look++ <
pl->contr->socket->container_position &&
pl !=
op)
355 if (
pl !=
op && objects_sent >=
pl->contr->socket->num_look_objects) {
360 SockList_AddInt(&sl, 0x80000000|(
pl->contr->socket->container_position + end_look - 1));
364 snprintf(
buf,
sizeof(
buf),
"Click here to see next group of items");
392 if (
pl !=
op &&
pl->contr->socket->container_position) {
397 pl->contr->socket->container_position =
MAX(0,
pl->contr->socket->container_position - prev_len);
463 op->contr->last_weight = weight;
481 strlcpy(item_n, custom_name,
sizeof(item_n)-1);
482 strlcpy(item_p, custom_name,
sizeof(item_p));
485 len = strlen(item_n)+1;
486 snprintf(item_n+len,
sizeof(item_n)-len,
"%s", item_p);
487 len += strlen(item_n+len);
498 anim_speed =
op->anim_speed;
500 if (
FABS(
op->speed) < 0.001)
502 else if (
FABS(
op->speed) >= 1.0)
507 if (anim_speed > 255)
534 pl->contr->socket->update_look = 1;
553 if (
pl->contr != NULL &&
pl->container != NULL &&
op->env ==
pl->container)
554 pl->contr->socket->update_inventory = 1;
575 if (
pl->ob->container != NULL &&
ob->env ==
pl->ob->container)
576 pl->socket->update_inventory = 1;
636 if (
pl->contr->transport) {
650 if (len <= 0 || !
buf) {
651 LOG(
llevDebug,
"Player '%s' sent bogus examine_cmd information\n",
pl->ob->name);
658 LOG(
llevDebug,
"Player '%s' tried to examine the unknown object (%ld)\n",
pl->ob->name,
tag);
672 if (!
buf || len <= 0) {
673 LOG(
llevDebug,
"Player '%s' sent bogus apply_cmd information\n",
pl->ob->name);
688 if (
tag&0x80000000) {
689 if (
pl->ob->container != NULL) {
690 pl->socket->container_position =
tag&0x7fffffff;
692 pl->socket->update_inventory = 0;
694 pl->socket->look_position =
tag&0x7fffffff;
695 pl->socket->update_look = 1;
701 LOG(
llevDebug,
"Player '%s' tried to apply the unknown object (%d)\n",
pl->ob->name,
tag);
715 LOG(
llevDebug,
"Player '%s' sent bogus lock_item_cmd information\n",
pl->ob->name);
724 "Could not find object to lock/unlock");
730 "Can't lock/unlock an item on the ground");
733 if (
op->env !=
pl->ob) {
735 "Can't lock/unlock an item not directly in your inventory");
743 "Unlocked %s.",
name);
773 LOG(
llevDebug,
"Player '%s' sent bogus mark_item_cmd information\n",
pl->ob->name);
781 "Could not find object to mark");
785 pl->mark_count =
op->count;
855 "You see nothing there.");
864 const int darkness =
pl->blocked_los[dx+(
pl->socket->mapx/2)][dy+(
pl->socket->mapy/2)];
873 if (len <= 0 || !
buf) {
874 LOG(
llevDebug,
"Player '%s' sent bogus look_at_cmd information\n",
pl->ob->name);
879 if (!(cp = strchr(
buf,
' '))) {
886 "You can't see there from where you're standing.");
892 "You can't see there from where you're standing.");
904 LOG(
llevDebug,
"Player '%s' tried to move an unknown object (%lu)\n",
pl->name, (
unsigned long)
tag);
911 if (!to && !
pl->contr->transport) {
914 if (
op->map && !
op->env) {
930 }
else if (to ==
pl->count) {
935 pl->contr->count = nrof;
940 if (
pl->contr->transport) {
948 LOG(
llevDebug,
"Player '%s' tried to move object to the unknown location (%d)\n",
pl->name, to);
965 object *scroll, *spell, *
marked, *inscription, *currentspell;
966 tag_t tscroll, tspell, tmarked;
970 LOG(
llevDebug,
"Player %s sent an invalid inscribe command.\n",
pl->ob->name);
984 LOG(
llevDebug,
"Player %s sent an invalid inscribe command.\n",
pl->ob->name);
992 LOG(
llevDebug,
"Player %s sent an invalid scroll for inscribe command.\n",
pl->ob->name);
998 LOG(
llevDebug,
"Player %s sent an invalid spell for inscribe command.\n",
pl->ob->name);
1002 tmarked =
pl->mark_count;
1006 pl->mark_count = tscroll;
1012 pl->mark_count = tmarked;
#define GET_MAP_OB(M, X, Y)
void SockList_AddInt(SockList *sl, uint32_t data)
void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof)
#define MSG_TYPE_COMMAND_SUCCESS
void LOG(LogLevel logLevel, const char *format,...)
void mark_item_cmd(uint8_t *data, int len, player *pl)
#define QUERY_FLAG(xyz, p)
object * object_merge(object *op, object *top)
void SockList_AddString(SockList *sl, const char *data)
void do_dump(object *who, object *what)
int write_on_item(object *pl, const char *params, object *skill)
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
void examine_cmd(char *buf, int len, player *pl)
static const flag_definition flags[]
#define MSG_TYPE_COMMAND_EXAMINE
void esrv_update_item(int flags, object *pl, object *op)
#define MSG_TYPE_COMMAND_ERROR
void SockList_Reset(SockList *sl)
const char * object_get_value(const object *op, const char *const key)
size_t SockList_Avail(const SockList *sl)
static event_registration m
void lock_item_cmd(uint8_t *data, int len, player *pl)
static void add_object_to_socklist(socket_struct *ns, SockList *sl, object *head)
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
void query_name(const object *op, char *buf, size_t size)
#define FLAG_KNOWN_BLESSED
#define FLAG_KNOWN_CURSED
#define FOR_OB_AND_BELOW_FINISH()
void SockList_AddShort(SockList *sl, uint16_t data)
int transport_can_hold(const object *transport, const object *op, int nrof)
void query_short_name(const object *op, char *buf, size_t size)
void SockList_AddChar(SockList *sl, unsigned char c)
int out_of_map(mapstruct *m, int x, int y)
static bool player_can_see(player *pl, int dx, int dy)
int is_identified(const object *op)
void esrv_send_inventory(object *pl, object *op)
static object * esrv_get_ob_from_count(object *pl, tag_t count)
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
#define FOR_OB_AND_BELOW_PREPARE(op_)
const Animations * animation
void SockList_Init(SockList *sl)
bool player_can_find(object *op, object *ob)
object * find_skill_by_name(object *who, const char *name)
static std::shared_ptr< inja::Environment > env
object * drop_object(object *op, object *tmp, uint32_t nrof)
size_t strlcpy(char *dst, const char *src, size_t size)
void SockList_Term(SockList *sl)
#define MSG_TYPE_COMMAND_FAILURE
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
#define FLAG_KNOWN_MAGICAL
void esrv_send_animation(socket_struct *ns, const Animations *anim)
#define MSG_TYPE_SKILL_FAILURE
void esrv_send_item(object *pl, object *op)
void esrv_del_item(player *pl, object *ob)
int object_can_pick(const object *who, const object *item)
void esrv_draw_look(object *pl)
const typedef char * sstring
static object * ob_if_can_find(object *op, object *ob)
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
int apply_by_living(object *pl, object *op, int aflag, int quiet)
void look_at(object *op, int dx, int dy)
#define CLEAR_FLAG(xyz, p)
uint8_t anims_sent[MAXANIMNUM]
void apply_cmd(char *buf, int len, player *pl)
int GetInt_String(const unsigned char *data)
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
void look_at_cmd(char *buf, int len, player *pl)
void inscribe_scroll_cmd(char *buf, int len, player *pl)
void inventory(object *op, object *inv)
void query_base_name(const object *op, int plural, char *buf, size_t size)
static unsigned int query_flags(const object *op)
#define FLAG_NO_SKILL_IDENT
void pick_up(object *op, object *alt)
void examine(object *op, object *tmp)
int sack_can_hold(const object *pl, const object *sack, const object *op, uint32_t nrof)
void Send_With_Handling(socket_struct *ns, SockList *sl)
#define CUSTOM_NAME_FIELD
#define FOR_INV_PREPARE(op_, it_)
void SockList_AddPrintf(SockList *sl, const char *format,...)
void put_object_in_sack(object *op, object *sack, object *tmp, uint32_t nrof)