… | |
… | |
40 | char buf[MAX_BUF], map_path[MAX_BUF]; |
40 | char buf[MAX_BUF], map_path[MAX_BUF]; |
41 | long sec = time (0); |
41 | long sec = time (0); |
42 | |
42 | |
43 | new_draw_info_format (NDI_UNIQUE, 0, op, "Current time is: %02ld:%02ld:%02ld.", (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60); |
43 | new_draw_info_format (NDI_UNIQUE, 0, op, "Current time is: %02ld:%02ld:%02ld.", (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60); |
44 | new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset"); |
44 | new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset"); |
45 | for (m = first_map; m != NULL; m = m->next) |
|
|
46 | { |
|
|
47 | |
45 | |
|
|
46 | for_all_maps (m) |
|
|
47 | { |
48 | if (search && strstr (m->path, search) == NULL) |
48 | if (search && !strstr (m->path, search)) |
49 | continue; /* Skip unwanted maps */ |
49 | continue; /* Skip unwanted maps */ |
|
|
50 | |
50 | /* Print out the last 18 characters of the map name... */ |
51 | /* Print out the last 18 characters of the map name... */ |
51 | if (strlen (m->path) <= 18) |
52 | if (strlen (m->path) <= 18) |
52 | strcpy (map_path, m->path); |
53 | strcpy (map_path, m->path); |
53 | else |
54 | else |
54 | strcpy (map_path, m->path + strlen (m->path) - 18); |
55 | strcpy (map_path, m->path + strlen (m->path) - 18); |
|
|
56 | |
55 | sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d", |
57 | sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d", |
56 | map_path, m->players, players_on_map (m, FALSE), |
58 | map_path, m->players, players_on_map (m, FALSE), |
57 | m->in_memory, m->timeout, m->difficulty, |
59 | m->in_memory, m->timeout, m->difficulty, |
58 | (MAP_WHEN_RESET (m) % 86400) / 3600, (MAP_WHEN_RESET (m) % 3600) / 60, MAP_WHEN_RESET (m) % 60); |
60 | (m->reset_time % 86400) / 3600, (m->reset_time % 3600) / 60, m->reset_time % 60); |
59 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
61 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 | } |
62 | } |
61 | } |
63 | } |
62 | |
64 | |
63 | /* This command dumps the body information for object *op. |
65 | /* This command dumps the body information for object *op. |
… | |
… | |
155 | |
157 | |
156 | if (QUERY_FLAG (op, FLAG_WIZ)) |
158 | if (QUERY_FLAG (op, FLAG_WIZ)) |
157 | { |
159 | { |
158 | new_draw_info_format (NDI_UNIQUE, 0, op, |
160 | new_draw_info_format (NDI_UNIQUE, 0, op, |
159 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
161 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
160 | m->players, m->difficulty, MAP_WIDTH (m), MAP_HEIGHT (m), MAP_ENTER_X (m), MAP_ENTER_Y (m), MAP_TIMEOUT (m)); |
162 | m->players, m->difficulty, m->width, m->height, m->enter_x, m->enter_y, m->timeout); |
161 | |
163 | |
162 | } |
164 | } |
163 | if (m->msg) |
165 | if (m->msg) |
164 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
166 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
165 | } |
167 | } |
… | |
… | |
192 | */ |
194 | */ |
193 | for (reg = first_region; reg != NULL; reg = reg->next) |
195 | for (reg = first_region; reg != NULL; reg = reg->next) |
194 | { |
196 | { |
195 | reg->counter = 0; |
197 | reg->counter = 0; |
196 | } |
198 | } |
197 | for (pl = first_player; pl != NULL; pl = pl->next) |
199 | for_all_players (pl) |
198 | if (pl->ob->map != NULL) |
200 | if (pl->ob->map != NULL) |
199 | get_region_by_map (pl->ob->map)->counter++; |
201 | get_region_by_map (pl->ob->map)->counter++; |
200 | |
202 | |
201 | /* we only want to print out by places with a 'longname' field... */ |
203 | /* we only want to print out by places with a 'longname' field... */ |
202 | for (reg = first_region; reg != NULL; reg = reg->next) |
204 | for (reg = first_region; reg != NULL; reg = reg->next) |
… | |
… | |
226 | } chars_names; |
228 | } chars_names; |
227 | |
229 | |
228 | int |
230 | int |
229 | command_afk (object *op, char *params) |
231 | command_afk (object *op, char *params) |
230 | { |
232 | { |
231 | if QUERY_FLAG |
233 | if ((op->contr->ns->afk = !op->contr->ns->afk)) |
232 | (op, FLAG_AFK) |
|
|
233 | { |
|
|
234 | CLEAR_FLAG (op, FLAG_AFK); |
|
|
235 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
234 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
236 | } |
|
|
237 | else |
235 | else |
238 | { |
|
|
239 | SET_FLAG (op, FLAG_AFK); |
|
|
240 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
236 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
241 | } |
237 | |
242 | return 1; |
238 | return 1; |
243 | } |
239 | } |
244 | |
240 | |
245 | int |
241 | int |
246 | command_mapinfo (object *op, char *params) |
242 | command_mapinfo (object *op, char *params) |
… | |
… | |
610 | |
606 | |
611 | int |
607 | int |
612 | command_fix_me (object *op, char *params) |
608 | command_fix_me (object *op, char *params) |
613 | { |
609 | { |
614 | sum_weight (op); |
610 | sum_weight (op); |
615 | fix_player (op); |
611 | op->update_stats (); |
616 | return 1; |
612 | return 1; |
617 | } |
613 | } |
618 | |
614 | |
619 | int |
615 | int |
620 | command_players (object *op, char *paramss) |
616 | command_players (object *op, char *paramss) |
… | |
… | |
1147 | } |
1143 | } |
1148 | |
1144 | |
1149 | int |
1145 | int |
1150 | command_real_quit (object *op, char *params) |
1146 | command_real_quit (object *op, char *params) |
1151 | { |
1147 | { |
1152 | send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
1148 | send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
1153 | |
1149 | |
1154 | op->contr->state = ST_CONFIRM_QUIT; |
1150 | op->contr->ns->state = ST_CONFIRM_QUIT; |
1155 | return 1; |
1151 | return 1; |
1156 | } |
1152 | } |
1157 | |
1153 | |
1158 | /* |
1154 | /* |
1159 | * don't allow people to exit explore mode. It otherwise becomes |
1155 | * don't allow people to exit explore mode. It otherwise becomes |
… | |
… | |
1183 | } |
1179 | } |
1184 | |
1180 | |
1185 | int |
1181 | int |
1186 | command_sound (object *op, char *params) |
1182 | command_sound (object *op, char *params) |
1187 | { |
1183 | { |
1188 | if (op->contr->socket->sound) |
1184 | if (op->contr->ns->sound) |
1189 | { |
1185 | { |
1190 | op->contr->socket->sound = 0; |
1186 | op->contr->ns->sound = 0; |
1191 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
1187 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
1192 | } |
1188 | } |
1193 | else |
1189 | else |
1194 | { |
1190 | { |
1195 | op->contr->socket->sound = 1; |
1191 | op->contr->ns->sound = 1; |
1196 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1192 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
1197 | } |
1193 | } |
1198 | |
1194 | |
1199 | return 1; |
1195 | return 1; |
1200 | } |
1196 | } |
1201 | |
|
|
1202 | /* Perhaps these should be in player.c, but that file is |
|
|
1203 | * already a bit big. |
|
|
1204 | */ |
|
|
1205 | |
|
|
1206 | void |
|
|
1207 | receive_player_name (object *op, char k) |
|
|
1208 | { |
|
|
1209 | |
|
|
1210 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1211 | { |
|
|
1212 | get_name (op); |
|
|
1213 | return; |
|
|
1214 | } |
|
|
1215 | op->name = op->contr->write_buf + 1; |
|
|
1216 | op->name_pl = op->contr->write_buf + 1; |
|
|
1217 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1218 | op->contr->name_changed = 1; |
|
|
1219 | get_password (op); |
|
|
1220 | } |
|
|
1221 | |
|
|
1222 | void |
|
|
1223 | receive_player_password (object *op, char k) |
|
|
1224 | { |
|
|
1225 | |
|
|
1226 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1227 | |
|
|
1228 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1229 | { |
|
|
1230 | get_name (op); |
|
|
1231 | return; |
|
|
1232 | } |
|
|
1233 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1234 | |
|
|
1235 | if (checkbanned (op->name, op->contr->socket->host)) |
|
|
1236 | { |
|
|
1237 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket->host); |
|
|
1238 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1239 | get_name (op); |
|
|
1240 | return; |
|
|
1241 | } |
|
|
1242 | |
|
|
1243 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1244 | { |
|
|
1245 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1246 | { |
|
|
1247 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1248 | get_name (op); |
|
|
1249 | return; |
|
|
1250 | } |
|
|
1251 | clear_win_info (op); |
|
|
1252 | display_motd (op); |
|
|
1253 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1254 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1255 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1256 | Roll_Again (op); |
|
|
1257 | op->contr->state = ST_ROLL_STAT; |
|
|
1258 | return; |
|
|
1259 | } |
|
|
1260 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1261 | op->contr->state = ST_ROLL_STAT; |
|
|
1262 | check_login (op); |
|
|
1263 | return; |
|
|
1264 | } |
|
|
1265 | |
|
|
1266 | |
1197 | |
1267 | int |
1198 | int |
1268 | explore_mode (void) |
1199 | explore_mode (void) |
1269 | { |
1200 | { |
1270 | player *pl; |
1201 | player *pl; |
… | |
… | |
1275 | if (pl->explore) |
1206 | if (pl->explore) |
1276 | return 1; |
1207 | return 1; |
1277 | } |
1208 | } |
1278 | return 0; |
1209 | return 0; |
1279 | } |
1210 | } |
1280 | |
|
|
1281 | |
1211 | |
1282 | int |
1212 | int |
1283 | command_title (object *op, char *params) |
1213 | command_title (object *op, char *params) |
1284 | { |
1214 | { |
1285 | char buf[MAX_BUF]; |
1215 | char buf[MAX_BUF]; |
… | |
… | |
1326 | } |
1256 | } |
1327 | |
1257 | |
1328 | int |
1258 | int |
1329 | command_save (object *op, char *params) |
1259 | command_save (object *op, char *params) |
1330 | { |
1260 | { |
1331 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1332 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1333 | // } else |
|
|
1334 | if (!op->stats.exp) |
1261 | if (!op->stats.exp) |
1335 | { |
|
|
1336 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
1262 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1263 | else |
1337 | } |
1264 | { |
1338 | else |
1265 | op->contr->save (); |
1339 | { |
|
|
1340 | if (save_player (op, 1)) |
|
|
1341 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
1266 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
1342 | else |
|
|
1343 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1344 | } |
1267 | } |
1345 | return 1; |
|
|
1346 | } |
|
|
1347 | |
1268 | |
|
|
1269 | return 1; |
|
|
1270 | } |
1348 | |
1271 | |
1349 | int |
1272 | int |
1350 | command_peaceful (object *op, char *params) |
1273 | command_peaceful (object *op, char *params) |
1351 | { |
1274 | { |
1352 | new_draw_info (NDI_UNIQUE, 0, op, |
1275 | new_draw_info (NDI_UNIQUE, 0, op, |
… | |
… | |
1361 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
1284 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
1362 | */ |
1285 | */ |
1363 | return 1; |
1286 | return 1; |
1364 | } |
1287 | } |
1365 | |
1288 | |
1366 | |
|
|
1367 | |
|
|
1368 | int |
1289 | int |
1369 | command_wimpy (object *op, char *params) |
1290 | command_wimpy (object *op, char *params) |
1370 | { |
1291 | { |
1371 | int i; |
1292 | int i; |
1372 | char buf[MAX_BUF]; |
1293 | char buf[MAX_BUF]; |
… | |
… | |
1381 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1302 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1382 | op->run_away = i; |
1303 | op->run_away = i; |
1383 | return 1; |
1304 | return 1; |
1384 | } |
1305 | } |
1385 | |
1306 | |
1386 | |
|
|
1387 | int |
1307 | int |
1388 | command_brace (object *op, char *params) |
1308 | command_brace (object *op, char *params) |
1389 | { |
1309 | { |
1390 | if (!params) |
1310 | if (!params) |
1391 | op->contr->braced = !op->contr->braced; |
1311 | op->contr->braced = !op->contr->braced; |
… | |
… | |
1395 | if (op->contr->braced) |
1315 | if (op->contr->braced) |
1396 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1316 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
1397 | else |
1317 | else |
1398 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1318 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
1399 | |
1319 | |
1400 | fix_player (op); |
1320 | op->update_stats (); |
1401 | return 0; |
1321 | return 0; |
1402 | } |
1322 | } |
1403 | |
1323 | |
1404 | int |
1324 | int |
1405 | command_style_map_info (object *op, char *params) |
1325 | command_style_map_info (object *op, char *params) |
… | |
… | |
1410 | object *tmp; |
1330 | object *tmp; |
1411 | |
1331 | |
1412 | for (mp = styles; mp != NULL; mp = mp->next) |
1332 | for (mp = styles; mp != NULL; mp = mp->next) |
1413 | { |
1333 | { |
1414 | maps_used++; |
1334 | maps_used++; |
1415 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
1335 | mapmem += mp->width * mp->height * (sizeof (object *) + sizeof (mapspace)) + sizeof (maptile); |
1416 | for (x = 0; x < MAP_WIDTH (mp); x++) |
1336 | for (x = 0; x < mp->width; x++) |
1417 | { |
1337 | { |
1418 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
1338 | for (y = 0; y < mp->height; y++) |
1419 | { |
1339 | { |
1420 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
1340 | for (tmp = GET_MAP_OB (mp, x, y); tmp != NULL; tmp = tmp->above) |
1421 | objects_used++; |
1341 | objects_used++; |
1422 | } |
1342 | } |
1423 | } |
1343 | } |
1424 | } |
1344 | } |
1425 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
1345 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |