Ignore:
Timestamp:
Apr 17, 2011, 10:28:20 AM (11 years ago)
Author:
Sam Hocevar
Message:

lisp: populate LispSymbol? with symbol-related methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/clisp.cpp

    r482 r484  
    3939
    4040// the following are references to lisp symbols
    41 void *l_difficulty,*l_easy,*l_hard,*l_medium,*l_main_menu,*l_extreme,
    42      *l_logo,*l_state_art,*l_abilities,*l_state_sfx,
    43      *l_song_list,*l_filename,*l_sfx_directory,*l_max_hp,*l_default_font,
    44      *l_morph,*l_max_power,*l_default_abilities,*l_default_ai_function,
    45      *l_tile_files,*l_empty_cache,*l_range,*l_hurt_all,*l_death_handler,
     41LispSymbol *l_chat_input, *l_post_render;
     42
     43LispSymbol *l_difficulty, *l_easy, *l_hard, *l_medium, *l_extreme,
     44    *l_max_hp, *l_max_power,
     45    *l_empty_cache;
     46
     47// FIXME: port these to LispSymbol
     48void *l_main_menu, *l_logo,*l_state_art,*l_abilities,*l_state_sfx,
     49     *l_song_list,*l_filename,*l_sfx_directory,*l_default_font,
     50     *l_morph,*l_default_abilities,*l_default_ai_function,
     51     *l_tile_files,*l_range,*l_hurt_all,*l_death_handler,
    4652     *l_title_screen,*l_console_font,*l_fields,*l_dist,*l_pushx,*l_pushy,
    4753     *l_object,*l_tile,*l_fire_object,*l_FIRE,*l_cop_dead_parts,*l_restart_player,
     
    5561     *l_ask_save_slot,
    5662     *l_get_local_input,
    57      *l_post_render,
    58      *l_chat_input,
    5963     *l_player_text_color,
    6064     *l_level_loaded;        // called when a new level is loaded
     
    99103                                             // to irnterface with c
    100104{
    101   l_easy=make_find_symbol("easy");
    102   l_medium=make_find_symbol("medium");
    103   l_hard=make_find_symbol("hard");
    104   l_extreme=make_find_symbol("extreme");
    105 
    106   l_logo=make_find_symbol("logo");
    107   l_morph=make_find_symbol("morph");
    108 
    109   l_pushx=make_find_symbol("pushx");
    110   l_pushy=make_find_symbol("pushy");
    111 
    112   l_dist=make_find_symbol("dist");
    113   l_state_art=make_find_symbol("state_art");
    114   l_abilities=make_find_symbol("abilities");
    115   l_default_abilities=make_find_symbol("default_abilities");
    116   l_state_sfx=make_find_symbol("state_sfx");
    117   l_filename=make_find_symbol("filename");
    118   l_sfx_directory=make_find_symbol("sfx_directory");
    119   l_default_font=make_find_symbol("default_font");
    120   l_console_font=make_find_symbol("console_font");
    121   l_default_ai_function=make_find_symbol("default_ai");
    122   l_tile_files=make_find_symbol("tile_files");
    123   l_empty_cache=make_find_symbol("empty_cache");
    124   l_range=make_find_symbol("range");
    125   l_difficulty=make_find_symbol("difficulty");
    126   l_death_handler=make_find_symbol("death_handler");
    127   l_title_screen=make_find_symbol("title_screen");
    128   l_fields=make_find_symbol("fields");
    129   l_FIRE=make_find_symbol("FIRE");
    130   l_fire_object=make_find_symbol("fire_object");
    131   l_cop_dead_parts=make_find_symbol("cop_dead_parts");  set_symbol_value(l_difficulty,l_hard);
    132   l_restart_player=make_find_symbol("restart_player");
    133   l_help_screens=make_find_symbol("help_screens");
    134   l_save_order=make_find_symbol("save_order");
    135   l_next_song=make_find_symbol("next_song");
    136   l_player_draw=make_find_symbol("player_draw");
    137   l_sneaky_draw=make_find_symbol("sneaky_draw");
    138   l_keep_backup=make_find_symbol("keep_backup");
    139   l_level_loaded=make_find_symbol("level_loaded");
    140 
    141   l_draw_fast=make_find_symbol("draw_fast");
    142   l_player_tints=make_find_symbol("player_tints");
    143 
    144   l_max_hp=make_find_symbol("max_hp");
    145   set_symbol_number(l_max_hp,200);
    146   l_max_power=make_find_symbol("max_power");
    147   l_main_menu=make_find_symbol("main_menu");
    148   set_symbol_number(l_max_power,999);
    149 
    150   set_symbol_number(make_find_symbol("run_state"),RUN_STATE);
    151   set_symbol_number(make_find_symbol("pause_state"),PAUSE_STATE);
    152   set_symbol_number(make_find_symbol("menu_state"),MENU_STATE);
    153   set_symbol_number(make_find_symbol("scene_state"),SCENE_STATE);
    154 
    155   l_statbar_ammo_x=make_find_symbol("statbar_ammo_x");
    156   l_statbar_ammo_y=make_find_symbol("statbar_ammo_y");
    157   l_statbar_ammo_w=make_find_symbol("statbar_ammo_w");
    158   l_statbar_ammo_h=make_find_symbol("statbar_ammo_h");
    159   l_statbar_ammo_bg_color=make_find_symbol("statbar_ammo_bg_color");
    160 
    161   l_statbar_health_x=make_find_symbol("statbar_health_x");
    162   l_statbar_health_y=make_find_symbol("statbar_health_y");
    163   l_statbar_health_w=make_find_symbol("statbar_health_w");
    164   l_statbar_health_h=make_find_symbol("statbar_health_h");
    165   l_statbar_health_bg_color=make_find_symbol("statbar_health_bg_color");
    166 
    167   l_statbar_logo_x=make_find_symbol("statbar_logo_x");
    168   l_statbar_logo_y=make_find_symbol("statbar_logo_y");
    169   l_object=make_find_symbol("object");
    170   l_tile=make_find_symbol("tile");
    171   l_cdc_logo=make_find_symbol("logo");
    172 
    173   l_switch_to_powerful=make_find_symbol("switch_to_powerful");
    174   l_mouse_can_switch=make_find_symbol("mouse_can_switch");
    175   l_ask_save_slot=make_find_symbol("ask_save_slot");
    176 
    177   l_level_load_start=make_find_symbol("level_load_start");
    178   l_level_load_end=make_find_symbol("level_load_end");
    179   l_get_local_input=make_find_symbol("get_local_input");
    180   l_chat_input=make_find_symbol("chat_input");
    181   l_player_text_color=make_find_symbol("player_text_color");
     105  l_easy = LispSymbol::FindOrCreate("easy");
     106  l_medium = LispSymbol::FindOrCreate("medium");
     107  l_hard = LispSymbol::FindOrCreate("hard");
     108  l_extreme = LispSymbol::FindOrCreate("extreme");
     109
     110  l_logo = LispSymbol::FindOrCreate("logo");
     111  l_morph = LispSymbol::FindOrCreate("morph");
     112
     113  l_pushx = LispSymbol::FindOrCreate("pushx");
     114  l_pushy = LispSymbol::FindOrCreate("pushy");
     115
     116  l_dist = LispSymbol::FindOrCreate("dist");
     117  l_state_art = LispSymbol::FindOrCreate("state_art");
     118  l_abilities = LispSymbol::FindOrCreate("abilities");
     119  l_default_abilities = LispSymbol::FindOrCreate("default_abilities");
     120  l_state_sfx = LispSymbol::FindOrCreate("state_sfx");
     121  l_filename = LispSymbol::FindOrCreate("filename");
     122  l_sfx_directory = LispSymbol::FindOrCreate("sfx_directory");
     123  l_default_font = LispSymbol::FindOrCreate("default_font");
     124  l_console_font = LispSymbol::FindOrCreate("console_font");
     125  l_default_ai_function = LispSymbol::FindOrCreate("default_ai");
     126  l_tile_files = LispSymbol::FindOrCreate("tile_files");
     127  l_empty_cache = LispSymbol::FindOrCreate("empty_cache");
     128  l_range = LispSymbol::FindOrCreate("range");
     129  l_difficulty = LispSymbol::FindOrCreate("difficulty");
     130  l_death_handler = LispSymbol::FindOrCreate("death_handler");
     131  l_title_screen = LispSymbol::FindOrCreate("title_screen");
     132  l_fields = LispSymbol::FindOrCreate("fields");
     133  l_FIRE = LispSymbol::FindOrCreate("FIRE");
     134  l_fire_object = LispSymbol::FindOrCreate("fire_object");
     135  l_cop_dead_parts = LispSymbol::FindOrCreate("cop_dead_parts");
     136  l_difficulty->SetValue(l_hard);
     137  l_restart_player = LispSymbol::FindOrCreate("restart_player");
     138  l_help_screens = LispSymbol::FindOrCreate("help_screens");
     139  l_save_order = LispSymbol::FindOrCreate("save_order");
     140  l_next_song = LispSymbol::FindOrCreate("next_song");
     141  l_player_draw = LispSymbol::FindOrCreate("player_draw");
     142  l_sneaky_draw = LispSymbol::FindOrCreate("sneaky_draw");
     143  l_keep_backup = LispSymbol::FindOrCreate("keep_backup");
     144  l_level_loaded = LispSymbol::FindOrCreate("level_loaded");
     145
     146  l_draw_fast = LispSymbol::FindOrCreate("draw_fast");
     147  l_player_tints = LispSymbol::FindOrCreate("player_tints");
     148
     149  l_max_hp = LispSymbol::FindOrCreate("max_hp");
     150  l_max_hp->SetNumber(200);
     151  l_max_power = LispSymbol::FindOrCreate("max_power");
     152  l_main_menu = LispSymbol::FindOrCreate("main_menu");
     153  l_max_power->SetNumber(999);
     154
     155  LispSymbol::FindOrCreate("run_state")->SetNumber(RUN_STATE);
     156  LispSymbol::FindOrCreate("pause_state")->SetNumber(PAUSE_STATE);
     157  LispSymbol::FindOrCreate("menu_state")->SetNumber(MENU_STATE);
     158  LispSymbol::FindOrCreate("scene_state")->SetNumber(SCENE_STATE);
     159
     160  l_statbar_ammo_x = LispSymbol::FindOrCreate("statbar_ammo_x");
     161  l_statbar_ammo_y = LispSymbol::FindOrCreate("statbar_ammo_y");
     162  l_statbar_ammo_w = LispSymbol::FindOrCreate("statbar_ammo_w");
     163  l_statbar_ammo_h = LispSymbol::FindOrCreate("statbar_ammo_h");
     164  l_statbar_ammo_bg_color = LispSymbol::FindOrCreate("statbar_ammo_bg_color");
     165
     166  l_statbar_health_x = LispSymbol::FindOrCreate("statbar_health_x");
     167  l_statbar_health_y = LispSymbol::FindOrCreate("statbar_health_y");
     168  l_statbar_health_w = LispSymbol::FindOrCreate("statbar_health_w");
     169  l_statbar_health_h = LispSymbol::FindOrCreate("statbar_health_h");
     170  l_statbar_health_bg_color = LispSymbol::FindOrCreate("statbar_health_bg_color");
     171
     172  l_statbar_logo_x = LispSymbol::FindOrCreate("statbar_logo_x");
     173  l_statbar_logo_y = LispSymbol::FindOrCreate("statbar_logo_y");
     174  l_object = LispSymbol::FindOrCreate("object");
     175  l_tile = LispSymbol::FindOrCreate("tile");
     176  l_cdc_logo = LispSymbol::FindOrCreate("logo");
     177
     178  l_switch_to_powerful = LispSymbol::FindOrCreate("switch_to_powerful");
     179  l_mouse_can_switch = LispSymbol::FindOrCreate("mouse_can_switch");
     180  l_ask_save_slot = LispSymbol::FindOrCreate("ask_save_slot");
     181
     182  l_level_load_start = LispSymbol::FindOrCreate("level_load_start");
     183  l_level_load_end = LispSymbol::FindOrCreate("level_load_end");
     184  l_get_local_input = LispSymbol::FindOrCreate("get_local_input");
     185  l_chat_input = LispSymbol::FindOrCreate("chat_input");
     186  l_player_text_color = LispSymbol::FindOrCreate("player_text_color");
    182187
    183188  int i;
    184189  for (i=0;i<MAX_STATE;i++)
    185     set_symbol_number(make_find_symbol(state_names[i]),i);
     190    LispSymbol::FindOrCreate(state_names[i])->SetNumber(i);
    186191  for (i=0;i<TOTAL_ABILITIES;i++)
    187     set_symbol_number(make_find_symbol(ability_names[i]),i);
     192    LispSymbol::FindOrCreate(ability_names[i])->SetNumber(i);
    188193  for (i=0;i<TOTAL_CFLAGS;i++)
    189     set_symbol_number(make_find_symbol(cflag_names[i]),i);
    190 
    191   l_song_list=make_find_symbol("song_list");
    192   l_post_render=make_find_symbol("post_render");
     194    LispSymbol::FindOrCreate(cflag_names[i])->SetNumber(i);
     195
     196  l_song_list = LispSymbol::FindOrCreate("song_list");
     197  l_post_render = LispSymbol::FindOrCreate("post_render");
    193198
    194199  add_c_function("distx",0,0,                   1);
     
    756761      if (item_type(sym)!=L_SYMBOL)
    757762      {
    758     lbreak("expecting first arg to def-character to be a symbol!\n");
    759     exit(0);
     763        lbreak("expecting first arg to def-character to be a symbol!\n");
     764        exit(0);
    760765      }
    761766      int sp=current_space;
    762767      current_space=PERM_SPACE;
    763       set_symbol_number(sym,total_objects);   // set the symbol value to the object number
     768      sym->SetNumber(total_objects);   // set the symbol value to the object number
    764769      current_space=sp;
    765770      if (!total_objects)
     
    774779      }
    775780
    776       object_names[total_objects] = strdup(lstring_value(symbol_name(sym)));
     781      object_names[total_objects] = strdup(lstring_value(sym->GetName()));
    777782      figures[total_objects]=new character_type(CDR(args),sym);
    778783      total_objects++;
     
    794799    {
    795800#ifdef __linux__
    796       return make_find_symbol("LINUX");
     801      return LispSymbol::FindOrCreate("LINUX");
    797802#endif
    798803#ifdef __sgi
    799       return make_find_symbol("IRIX");
     804      return LispSymbol::FindOrCreate("IRIX");
    800805#endif
    801806#ifdef __WIN32
    802       return make_find_symbol("WIN32");
     807      return LispSymbol::FindOrCreate("WIN32");
    803808#endif
    804809    } break;
     
    13661371      int id=cache.reg(lstring_value(lcar(args)),NULL,SPEC_EXTERN_SFX,1);
    13671372      if (sym)
    1368         set_symbol_number(sym,id);    // set the symbol value to sfx id               
     1373        sym->SetNumber(id);    // set the symbol value to sfx id
    13691374      current_space=sp;
    13701375      return id;
Note: See TracChangeset for help on using the changeset viewer.