Changeset 833
- Timestamp:
- 05/08/07 21:20:11 (2 years ago)
- Files:
-
- 1.8.3/branches/experimental/hdrs/game.h (modified) (1 diff)
- 1.8.3/branches/experimental/src/command.c (modified) (3 diffs)
- 1.8.3/branches/experimental/src/game.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/branches/experimental/hdrs/game.h
r832 r833 20 20 extern void init_flag_table(const char *ns); /* flags.c */ 21 21 extern void init_pronouns(void); /* funstr.c */ 22 void init_switches(void); /* command.c */ 22 23 23 24 /* From bsd.c */ 1.8.3/branches/experimental/src/command.c
r803 r833 40 40 PTAB ptab_command; /**< Prefix table for command names. */ 41 41 PTAB ptab_command_perms; /**< Prefix table for command permissions */ 42 PTAB ptab_switches; /**< Prefix table for command switches. */ 42 43 43 44 HASHTAB htab_reserved_aliases; /**< Hash table for reserved command aliases */ … … 367 368 #include "switchinc.c" 368 369 370 void 371 init_switches(void) { 372 SWITCH_VALUE *v; 373 374 ptab_init(&ptab_switches); 375 376 ptab_start_inserts(&ptab_switches); 377 for (v = switch_list; v->name; v++) 378 ptab_insert(&ptab_switches, v->name, v); 379 ptab_end_inserts(&ptab_switches); 380 } 381 369 382 /** Table of command permissions/restrictions. */ 370 383 struct command_perms_t command_perms[] = { … … 404 417 safe_str(from, buff, bp); 405 418 } 419 406 420 static int 407 421 switch_find(COMMAND_INFO *cmd, char *sw) 408 422 { 409 423 SWITCH_VALUE *sw_val; 410 int i = 0; 411 int len; 424 412 425 if (!sw || !*sw) 413 426 return 0; 414 len = strlen(sw); 427 415 428 /* Special case, for init */ 416 sw_val = switch_list;417 429 if (!cmd) { 418 while (sw_val->name) { 419 if (strcmp(sw_val->name, sw) == 0) 420 return sw_val->value; 421 sw_val++; 422 } 423 return 0; 430 sw_val = ptab_find_exact(&ptab_switches, sw); 431 if (sw_val) 432 return sw_val->value; 433 else 434 return 0; 424 435 } else { 425 while (sw_val->name) { 426 i++; 427 if (SW_ISSET(cmd->sw, i) && (strncmp(sw_val->name, sw, len) == 0)) 428 return i; 429 sw_val++; 430 } 431 } 432 return 0; 436 sw_val = ptab_find(&ptab_switches, sw); 437 if (sw_val && SW_ISSET(cmd->sw, sw_val->value)) 438 return sw_val->value; 439 else 440 return 0; 441 } 433 442 } 434 443 1.8.3/branches/experimental/src/game.c
r832 r833 733 733 init_names(); 734 734 init_pronouns(); 735 init_switches(); 735 736 736 737 memset(¤t_state, 0, sizeof current_state); … … 2334 2335 extern PTAB ptab_attrib; 2335 2336 extern PTAB ptab_flag; 2337 extern PTAB ptab_switches; 2336 2338 2337 2339 /** Reports stats on various in-memory data structures. … … 2355 2357 ptab_stats(player, &ptab_command, "Commands"); 2356 2358 ptab_stats(player, &ptab_flag, "Flags"); 2359 ptab_stats(player, &ptab_switches, "Switches"); 2357 2360 notify(player, "String Trees:"); 2358 2361 st_stats_header(player);
