Crossfire Server, Trunk
c_new.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include "global.h"
20 
21 #include <stdlib.h>
22 #include <string.h>
23 #include <ctype.h>
24 
25 #include "commands.h"
26 #include "sproto.h"
27 
28 #ifndef tolower
29 
30 #define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C)-'A'+'a' : (C))
31 #endif
32 
41 void command_run(object *op, const char *params) {
42  int dir;
43 
44  dir = atoi(params);
45  if (dir < 0 || dir >= 9) {
47  "Can't run into a non adjacent square.");
48  return;
49  }
50  op->contr->run_on = 1;
51  move_player(op, dir);
52 }
53 
64 void command_run_stop(object *op, const char *params) {
65  (void)params;
66  op->contr->run_on = 0;
67 }
68 
77 void command_fire(object *op, const char *params) {
78  int dir;
79 
80  dir = atoi(params);
81  if (dir < 0 || dir >= 9) {
83  "Can't fire to a non adjacent square.");
84  return;
85  }
86  op->contr->fire_on = 1;
87  move_player(op, dir);
88 }
89 
98 void command_fire_stop(object *op, const char *params) {
99  (void)params;
100  op->contr->fire_on = 0;
101 }
102 
111 void command_face(object *op, const char *params) {
112  int dir;
113 
114  if ( !isdigit(*params) ) {
115  if ( strcmp(params,"stay") == 0 || strcmp(params,"down") == 0 ) dir=0;
116  else if ( strcmp(params,"north") == 0 || strcmp(params,"n") == 0 ) dir=1;
117  else if ( strcmp(params,"northeast") == 0 || strcmp(params,"ne") == 0 ) dir=2;
118  else if ( strcmp(params,"east") == 0 || strcmp(params,"e") == 0 ) dir=3;
119  else if ( strcmp(params,"southeast") == 0 || strcmp(params,"se") == 0 ) dir=4;
120  else if ( strcmp(params,"south") == 0 || strcmp(params,"s") == 0 ) dir=5;
121  else if ( strcmp(params,"southwest") == 0 || strcmp(params,"sw") == 0 ) dir=6;
122  else if ( strcmp(params,"west") == 0 || strcmp(params,"w") == 0 ) dir=7;
123  else if ( strcmp(params,"northwest") == 0 || strcmp(params,"nw") == 0 ) dir=8;
124  else {
126  "Unknown direction to face: %s",params);
127  return;
128  }
129  }
130  else dir = atoi(params);
131  if (dir < 0 || dir >= 9) {
133  "Can't face to a non adjacent square.");
134  return;
135  }
136  face_player(op, dir);
137 }
global.h
command_run_stop
void command_run_stop(object *op, const char *params)
Definition: c_new.c:64
move_player
int move_player(object *op, int dir)
Definition: player.c:2923
command_face
void command_face(object *op, const char *params)
Definition: c_new.c:111
MSG_TYPE_COMMAND_ERROR
#define MSG_TYPE_COMMAND_ERROR
Definition: newclient.h:529
command_run
void command_run(object *op, const char *params)
Definition: c_new.c:41
command_fire
void command_fire(object *op, const char *params)
Definition: c_new.c:77
MSG_TYPE_COMMAND
#define MSG_TYPE_COMMAND
Definition: newclient.h:404
face_player
int face_player(object *op, int dir)
Definition: player.c:3002
sproto.h
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
command_fire_stop
void command_fire_stop(object *op, const char *params)
Definition: c_new.c:98
give.op
op
Definition: give.py:33
roll-o-matic.params
params
Definition: roll-o-matic.py:193
draw_ext_info
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Definition: main.c:309
commands.h
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition: main.c:319