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