Changeset 124
- Timestamp:
- Mar 18, 2008, 9:36:56 PM (14 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 212 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/ability.cpp
r56 r124 13 13 #include "chars.hpp" 14 14 15 /*int abil[TOTAL_OBJECTS*TOTAL_ABILITIES]= { 15 /*int abil[TOTAL_OBJECTS*TOTAL_ABILITIES]= { 16 16 / hp starta stopa jumpxv jumpyv crouch_tops run_tops jmp_tops wlk_tops / 17 17 / human / 50, 3, 4, 8, -24, 3, 6, 8, 4, 18 / iguana / 4, 3, 4, 10, -34, 0, 8, 10, 6, 18 / iguana / 4, 3, 4, 10, -34, 0, 8, 10, 6, 19 19 / who / 2, 2, 4, 20, 0, 0, 18, 20, 18, 20 20 … … 41 41 42 42 long abil_def[TOTAL_ABILITIES]= 43 {6, 3, 4, 2, -16, 10, 6, 0, 43 {6, 3, 4, 2, -16, 10, 6, 0, 44 44 /* hp starta stopa jumpxv jumpyv run_tops jmp_tops blood_type */ 45 45 46 46 /* push_xrange wlk_tops */ 47 47 0, 6 }; -
abuse/trunk/src/ability.hpp
r57 r124 12 12 13 13 enum ability 14 { 15 16 14 { start_hp, 15 start_accel, 16 stop_accel, 17 17 jump_xvel, 18 19 20 18 jump_yvel, 19 run_top_speed, 20 jump_top_speed, 21 21 22 23 24 22 tint_color, 23 push_xrange, 24 walk_top_speed // keep as last entry! 25 25 } ; 26 26 -
abuse/trunk/src/ant.cpp
r123 r124 24 24 25 25 enum { ANT_need_to_dodge, // ant vars 26 27 26 ANT_no_see_time, 27 ANT_hide_flag }; 28 28 29 29 int can_see(game_object *o, int32_t x1, int32_t y1, int32_t x2, int32_t y2) … … 44 44 { 45 45 if (o->lvars[ANT_no_see_time]==0 || o->lvars[ANT_no_see_time]>20) 46 the_game->play_sound(S_ASCREAM_SND,127,o->x,o->y); 46 the_game->play_sound(S_ASCREAM_SND,127,o->x,o->y); 47 47 o->lvars[ANT_no_see_time]=1; 48 48 } else o->lvars[ANT_no_see_time]++; … … 69 69 if (!can_see(o,o->x,o->y,o->x,o->y-120)) // is there a roof above? 70 70 { 71 72 73 74 71 o->set_yvel(-17); 72 o->set_xvel(0); 73 o->set_aistate(ANT_JUMP_ROOF); 74 ant_ai(); 75 75 } else 76 76 { 77 78 79 80 81 77 o->set_yvel(-12); 78 if (o->direction>0) 79 o->set_xvel(22); 80 else o->set_xvel(-22); 81 o->set_aistate(ANT_JUMP); 82 82 } 83 83 } … … 99 99 100 100 static int can_hit_player(game_object *o, game_object *b) 101 { 101 { 102 102 return can_see(o,o->x+(o->direction>0?15:-15),o->y-15,b->x,b->y-15); 103 103 } … … 158 158 if (o->otype!=S_HIDDEN_ANT) 159 159 { 160 161 162 160 o->change_type(S_HIDDEN_ANT); // switch types so noone hurts us. 161 o->set_state(stopped); 162 o->set_aistate(ANT_HIDING); 163 163 } 164 164 … … 166 166 if (o->total_objects()==0) 167 167 { 168 169 170 171 172 173 } 168 if (player_list->next) 169 b=current_level->attacker(current_object); 170 else b=player_list->focus; 171 if (abs(b->x-o->x)<130 && (o->y<b->y)) 172 fall=1; 173 } 174 174 else if (o->get_object(0)->aistate()!=0) 175 175 fall=1; 176 176 177 177 if (fall) 178 178 { 179 180 181 182 179 o->change_type(S_ANT_ROOF); 180 o->set_state((character_state)S_falling); 181 o->set_aistate(ANT_FALL_DOWN); 182 o->set_targetable(1); 183 183 } else o->set_targetable(0); 184 184 } break; … … 191 191 else 192 192 { 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 } 213 193 o->set_state((character_state)S_hanging); 194 if (o->total_objects()) 195 { 196 if (o->get_object(0)->aistate()!=0) 197 fall=1; 198 } else 199 { 200 if (player_list->next) 201 b=current_level->attacker(current_object); 202 else b=player_list->focus; 203 if (abs(b->x-o->x)<130 && (o->y<b->y)) 204 fall=1; 205 } 206 if (fall) 207 { 208 o->set_state((character_state)S_fall_start); 209 o->set_aistate(ANT_FALL_DOWN); 210 o->set_targetable(1); 211 } else o->set_targetable(0); 212 } 213 214 214 } break; 215 215 case ANT_FALL_DOWN : 216 216 { 217 217 o->set_state((character_state)S_falling); 218 218 219 219 if (player_list->next) 220 220 b=current_level->attacker(current_object); 221 221 else b=player_list->focus; 222 222 223 223 scream_check(o,b); 224 224 int ret=o->mover(0,0,0); 225 225 if ((ret&BLOCKED_DOWN) || !can_see(o,o->x,o->y,o->x,o->y+1)) 226 226 { 227 228 229 227 o->set_state((character_state)S_landing); 228 the_game->play_sound(S_ALAND_SND,127,o->x,o->y); 229 o->set_aistate(ANT_LANDING); 230 230 } 231 231 } break; … … 234 234 if (!o->next_picture()) 235 235 { 236 237 238 239 240 241 242 243 244 { 245 246 247 248 236 int32_t xv=0,yv=2; 237 o->try_move(o->x,o->y,xv,yv,1); 238 if (yv!=0) 239 { 240 o->set_gravity(1); 241 o->set_aistate(ANT_FALL_DOWN); 242 } 243 else 244 { 245 o->set_state(stopped); 246 o->set_aistate(ANT_RUNNING); 247 return (void *)ant_ai; 248 } 249 249 } 250 250 } break; … … 255 255 else b=player_list->focus; 256 256 scream_check(o,b); 257 258 259 if ((jrand()%16)==0) 257 258 259 if ((jrand()%16)==0) 260 260 o->lvars[ANT_need_to_dodge]=1; 261 261 if (!ant_dodge(o)) 262 262 { 263 264 265 266 267 268 269 270 271 272 273 274 else 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 } 315 } break; 316 263 if ((o->x>b->x && o->direction==-1) || (o->x<b->x && o->direction==1)) 264 { 265 o->next_picture(); 266 if ((jrand()%4)==0 && abs(o->x-b->x)<180 && abs(o->y-b->y)<100 && can_hit_player(o,b)) 267 { 268 o->set_state((character_state)S_weapon_fire); 269 o->set_aistate(ANT_FIRE); 270 } else if (abs(o->x-b->x)<100 && abs(o->y-b->y)<10 && (jrand()%4)==0) 271 o->set_aistate(ANT_POUNCE_WAIT); 272 else if (abs(o->x-b->x)>140 && !ant_congestion(o)) 273 o->set_aistate(ANT_JUMP); 274 else 275 { 276 int32_t xm=o->direction>0 ? get_ability(o->otype,run_top_speed) : -get_ability(o->otype,run_top_speed); 277 int32_t ym=0,new_xm=xm; 278 if (o->state!=running) o->set_state(running); 279 280 o->try_move(o->x,o->y,new_xm,ym,3); 281 if (new_xm!=xm) // blocked, see if we can climb ramp 282 { 283 new_xm=xm; 284 ym=-abs(xm); 285 o->try_move(o->x,o->y,new_xm,ym,3); 286 if (new_xm==xm) 287 { 288 o->x+=new_xm; 289 o->y+=ym; 290 new_xm=0; 291 ym=abs(xm); // now get back on the ground 292 o->try_move(o->x,o->y,new_xm,ym,3); 293 o->x+=new_xm; 294 o->y+=ym; 295 } else 296 { 297 o->direction=0-o->direction; 298 o->set_aistate(ANT_JUMP); 299 } 300 } else 301 o->x+=new_xm; 302 new_xm=0; 303 ym=10; // see if we should fall 304 o->try_move(o->x,o->y,new_xm,ym,3); 305 if (ym==10) 306 o->set_aistate(ANT_FALL_DOWN); 307 else o->y+=ym; 308 } 309 } else 310 { 311 o->direction=o->x>b->x ? -1 : 1; 312 o->set_aistate(ANT_LANDING); 313 } 314 } 315 } break; 316 317 317 case ANT_POUNCE_WAIT : 318 318 { 319 319 if (!ant_dodge(o)) 320 320 { 321 322 323 324 325 326 327 321 o->set_state((character_state)S_pounce_wait); 322 if (o->aistate_time()>alien_wait_time()) 323 { 324 the_game->play_sound(S_ASLASH_SND,127,o->x,o->y); 325 o->set_state(stopped); 326 o->set_aistate(ANT_JUMP); 327 } 328 328 } 329 329 } break; … … 333 333 o->lvars[ANT_need_to_dodge]=0; 334 334 if (o->move(o->direction,-1,0)&BLOCKED_DOWN) 335 o->set_aistate(ANT_RUNNING); 335 o->set_aistate(ANT_RUNNING); 336 336 } break; 337 337 case ANT_FIRE : … … 339 339 if (!ant_dodge(o)) 340 340 { 341 342 343 344 345 346 347 348 349 350 351 352 341 if (o->state==S_fire_wait) 342 { 343 if (!o->next_picture() || symbol_value(l_difficulty)==l_extreme) 344 { 345 if (player_list->next) 346 b=current_level->attacker(current_object); 347 else b=player_list->focus; 348 fire_at_player(o,b); 349 o->set_state(stopped); 350 o->set_aistate(ANT_RUNNING); 351 } 352 } else o->set_state((character_state)S_fire_wait); 353 353 } 354 354 } break; … … 365 365 if (yv!=o->yvel()) 366 366 { 367 368 369 370 371 372 373 374 375 376 367 if (o->yvel()>0) 368 { 369 o->set_state(stopped); 370 o->set_aistate(ANT_RUNNING); 371 } else 372 { 373 o->set_state((character_state)S_top_walk); 374 o->set_aistate(ANT_ROOF_WALK); 375 } 376 o->set_yvel(0); 377 377 } 378 378 } break; … … 382 382 b=current_level->attacker(current_object); 383 383 else b=player_list->focus; 384 scream_check(o,b); 384 scream_check(o,b); 385 385 if (((jrand()%8)==0 && abs(o->x-b->x)<10 && o->y<b->y) || 386 387 { 388 389 390 391 386 o->lvars[ANT_need_to_dodge]==1) 387 { 388 o->set_gravity(1); 389 o->set_state(run_jump); 390 o->set_aistate(ANT_JUMP); 391 ant_ai(); 392 392 } 393 393 else 394 394 { 395 396 397 398 399 400 401 402 403 404 int speed=o->direction>0 ? get_ability(o->otype,run_top_speed) : 405 406 407 408 409 410 411 412 413 395 if ((o->x>b->x && o->direction>0) || (o->x<b->x && o->direction<0)) 396 o->direction=-o->direction; 397 else if (abs(o->x-b->x)<120 && (jrand()%4)==0) 398 { 399 o->set_state((character_state)S_ceil_fire); 400 o->set_aistate(ANT_CEIL_SHOOT); 401 ant_ai(); 402 } else 403 { 404 int speed=o->direction>0 ? get_ability(o->otype,run_top_speed) : 405 -get_ability(o->otype,run_top_speed); 406 if (can_see(o,o->x,o->y-31,o->x+speed,o->y-31) && 407 !can_see(o,o->x+speed,o->y-31,o->x+speed,o->y-32)) 408 { 409 o->x+=speed; 410 if (!o->next_picture()) o->set_state((character_state)S_top_walk); 411 412 } else o->set_aistate(ANT_FALL_DOWN); 413 } 414 414 } 415 415 } break; … … 418 418 if (!o->next_picture()) 419 419 { 420 421 422 423 424 425 426 } 427 } break; 428 } 429 430 431 420 if (player_list->next) 421 b=current_level->attacker(current_object); 422 else b=player_list->focus; 423 fire_at_player(o,b); 424 o->set_state((character_state)S_top_walk); 425 o->set_aistate(ANT_ROOF_WALK); 426 } 427 } break; 428 } 429 430 431 432 432 return true_symbol; 433 433 } … … 457 457 char dig2=name[strlen(name)-strlen(".spe")-1]; 458 458 459 459 460 460 char msg[50]; 461 461 … … 468 468 } else sprintf(msg,"%s : %s",symbol_str("lev_complete"),current_level->original_name()); 469 469 470 int w=wm->font()->width()*strlen(msg),h=wm->font()->height(); 470 int w=wm->font()->width()*strlen(msg),h=wm->font()->height(); 471 471 int x=(x1+x2)/2-w/2,y=(y1+y2)/2-h/2; 472 472 screen->bar(x-10,y-10,x+w+10,y+h+10,wm->bright_color()); 473 473 screen->bar(x-9,y-9,x+w+9,y+h+9,wm->medium_color()); 474 474 475 wm->font()->put_string(screen,x+1,y+1,msg,wm->dark_color()); 475 wm->font()->put_string(screen,x+1,y+1,msg,wm->dark_color()); 476 476 wm->font()->put_string(screen,x,y,msg,wm->bright_color()); 477 477 wm->flush_screen(); -
abuse/trunk/src/automap.cpp
r123 r124 19 19 if (!automap_window) return ; 20 20 image *screen=automap_window->screen; 21 21 22 22 long sx,ex,sy,ey,x,y,window_xstart,window_ystart, 23 23 window_xend,window_yend,centerx,centery, 24 24 draw_xstart,draw_ystart, 25 25 i,j; 26 26 27 27 x=the_game->first_view->x_center(); 28 28 y=the_game->first_view->y_center(); 29 29 30 31 window_xstart=automap_window->x1(); 30 31 window_xstart=automap_window->x1(); 32 32 window_ystart=automap_window->y1(); 33 window_xend=automap_window->x2(); 33 window_xend=automap_window->x2(); 34 34 window_yend=automap_window->y2(); 35 35 centerx=(window_xstart+window_xend)/2; 36 36 centery=(window_ystart+window_yend)/2; 37 38 sx=x/f_wid-w/2; // start drawing with this foretile 37 38 sx=x/f_wid-w/2; // start drawing with this foretile 39 39 sy=y/f_hi-h/2; 40 ex=sx+w; 41 ey=sy+h; 40 ex=sx+w; 41 ey=sy+h; 42 42 43 43 if (sx<0) // does the map scroll past the left side ? 44 { sx=0; // yes, start drawing at 0 44 { sx=0; // yes, start drawing at 0 45 45 draw_xstart=centerx-(x*AUTOTILE_WIDTH/f_wid); 46 46 } 47 47 else 48 48 draw_xstart=centerx-(x*AUTOTILE_WIDTH/f_wid-sx*AUTOTILE_WIDTH); 49 50 if (sy<0) 51 { 52 sy=0; 49 50 if (sy<0) 51 { 52 sy=0; 53 53 draw_ystart=centery-(y*AUTOTILE_HEIGHT/f_hi); 54 54 } … … 57 57 58 58 // if view position hasn't changed, only update the binking dot and return 59 if (draw_xstart==old_dx && draw_ystart==old_dy) 59 if (draw_xstart==old_dx && draw_ystart==old_dy) 60 60 { 61 61 automap_window->screen->lock(); … … 63 63 if ((tick++)&4) 64 64 automap_window->screen->putpixel(centerx,centery,255); 65 else 65 else 66 66 automap_window->screen->putpixel(centerx,centery,27); 67 67 automap_window->screen->unlock(); 68 return ; 68 return ; 69 69 } 70 70 71 71 old_dx=draw_xstart; 72 old_dy=draw_ystart; 73 74 75 if (ex>=cur_lev->foreground_width()) 72 old_dy=draw_ystart; 73 74 75 if (ex>=cur_lev->foreground_width()) 76 76 ex=cur_lev->foreground_width()-1; 77 77 if (ey>=cur_lev->foreground_height()) … … 81 81 screen->bar(window_xstart,window_ystart,draw_xstart,window_yend,0); 82 82 screen->bar(window_xstart,window_ystart,window_xend,draw_ystart,0); 83 83 84 84 85 85 /* if (ex>=cur_lev->foreground_width()) 86 { 86 { 87 87 draw_xend=center 88 88 ex=foreground_width()-1; */ 89 89 90 90 91 91 92 92 … … 95 95 screen->add_dirty(window_xstart,window_ystart,window_xend,window_yend); 96 96 97 97 98 98 99 99 … … 116 116 117 117 118 118 119 119 unsigned short *fgline; 120 120 for (j=draw_ystart,y=sy;y<=ey;j+=AUTOTILE_HEIGHT,y++) 121 { 121 { 122 122 fgline=cur_lev->get_fgline(y)+sx; 123 123 for (i=draw_xstart,x=sx;x<=ex;i+=AUTOTILE_WIDTH,x++,fgline++) … … 125 125 if ((*fgline)&0x8000) 126 126 { 127 128 127 int id=foretiles[ (*fgline)&0x7fff]; 128 if (id>=0) 129 129 cache.foret(id)->micro_image->put_image(screen,i,j,0); 130 130 else 131 131 cache.foret(foretiles[0])->micro_image->put_image(screen,i,j,0); 132 132 } … … 137 137 } 138 138 139 } 139 } 140 140 141 141 … … 145 145 if ((tick++)&4) 146 146 automap_window->screen->putpixel(centerx,centery,255); 147 else 147 else 148 148 automap_window->screen->putpixel(centerx,centery,27); 149 149 automap_window->screen->unlock(); 150 150 151 151 // set the clip back to full window size because soemthing else could mess with the area 152 automap_window->screen->set_clip(0,0,screen->width()-1,screen->height()-1); 152 automap_window->screen->set_clip(0,0,screen->width()-1,screen->height()-1); 153 153 } 154 154 … … 157 157 { 158 158 if (automap_window) 159 { 159 { 160 160 wm->close_window(automap_window); 161 161 automap_window = NULL; 162 162 } 163 163 else 164 { 164 { 165 165 old_dx = -1000; // make sure the map gets drawn the first time 166 166 old_dy = -1000; … … 169 169 h * AUTOTILE_HEIGHT, NULL, "Map"); 170 170 automap_window->screen->bar(17, 1, 17 + 8 * 6 + 3, 6, 171 wm->medium_color()); 171 wm->medium_color()); 172 172 wm->font()->put_string(automap_window->screen, 20, 2, "Automap", 173 173 wm->dark_color()); 174 draw(); 175 } 174 draw(); 175 } 176 176 } 177 177 … … 181 181 w=width; 182 182 h=height; 183 184 tick=0; 183 184 tick=0; 185 185 cur_lev=l; 186 186 automap_window=NULL; 187 toggle_window(); 187 toggle_window(); 188 188 } 189 189 … … 198 198 case EV_KEY : 199 199 switch(ev.key) 200 201 case 'A' : 202 203 204 break;205 } 206 break; 200 { 201 case 'A' : 202 case 'a' : 203 toggle_window(); 204 break; 205 } 206 break; 207 207 case EV_CLOSE_WINDOW : 208 208 wm->close_window(automap_window); 209 210 break;211 } 212 } 213 } 214 215 216 217 218 219 220 209 automap_window=NULL; 210 break; 211 } 212 } 213 } 214 215 216 217 218 219 220 -
abuse/trunk/src/automap.hpp
r120 r124 15 15 16 16 class automap 17 { 17 { 18 18 Jwindow *automap_window; 19 19 level *cur_lev; -
abuse/trunk/src/cache.cpp
r123 r124 34 34 35 35 #define touch(x) { (x)->last_access=last_access++; \ 36 36 if ((x)->last_access<0) { normalize(); (x)->last_access=1; } } 37 37 38 38 CrcManager crc_manager; … … 62 62 if (!fp->open_failure()) 63 63 { 64 65 64 set_crc(i,crc_file(fp)); 65 total++; 66 66 } 67 67 delete fp; … … 75 75 { 76 76 delete fp; 77 return 0; 77 return 0; 78 78 } 79 79 … … 95 95 } 96 96 delete fp; 97 return 1; 97 return 1; 98 98 } 99 99 … … 119 119 delete fp; 120 120 } 121 return 1; 121 return 1; 122 122 } 123 123 … … 137 137 } 138 138 139 CrcedFile::CrcedFile(char const *name) 140 { 139 CrcedFile::CrcedFile(char const *name) 140 { 141 141 filename=strcpy((char *)jmalloc(strlen(name)+1,"crc_file"),name); 142 142 crc_calculated=0; … … 166 166 167 167 uint32_t CrcManager::get_crc(int32_t filenumber, int &failed) 168 { 168 { 169 169 CHECK(filenumber>=0 && filenumber<total_files); 170 if (files[filenumber]->crc_calculated) 170 if (files[filenumber]->crc_calculated) 171 171 { 172 172 failed=0; … … 210 210 if (prof_data) 211 211 jfree(prof_data); 212 212 213 213 prof_data=(int *)jmalloc(sizeof(int)*total,"cache profile"); 214 214 memset(prof_data,0,sizeof(int)*total); … … 262 262 for (i=0;i<crc_manager.total_filenames();i++) 263 263 { 264 264 int l=strlen(crc_manager.get_filename(i))+1; 265 265 fp->write_uint8(l); 266 266 fp->write(crc_manager.get_filename(i),l); 267 267 } 268 268 … … 274 274 for (i=0;i<total;i++) 275 275 { 276 277 if (list[id].last_access>0) // don't save unaccessed counts 278 279 fp->write_uint8(list[id].type); // save type, if type changed on reload 280 281 282 283 284 } 276 int id=ordered_ids[i]; 277 if (list[id].last_access>0) // don't save unaccessed counts 278 { 279 fp->write_uint8(list[id].type); // save type, if type changed on reload 280 // don't cache in-> its a different refrence 281 fp->write_uint16(list[id].file_number); 282 fp->write_uint32(list[id].offset); 283 } 284 } 285 285 } 286 286 … … 330 330 CacheItem *e=list+sarray[split]; 331 331 332 if (e->offset<offset) // search to the right 332 if (e->offset<offset) // search to the right 333 333 x1=split+1; 334 334 else if (e->offset>offset) … … 356 356 } 357 357 return 1; 358 358 359 359 } 360 360 … … 372 372 { 373 373 if (!figures[type]->get_cflag(CFLAG_NEED_CACHE_IN)) // see if it's already marked 374 { 374 { 375 375 figures[type]->set_cflag(CFLAG_NEED_CACHE_IN,1); 376 376 void *cache_fun=figures[type]->get_fun(OFUN_GET_CACHE_LIST); … … 378 378 if (cache_fun) 379 379 { 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 } 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 380 int sp=current_space; 381 current_space=PERM_SPACE; 382 383 void *call_with=NULL; 384 push_onto_list(new_lisp_number(type),call_with); 385 386 void *CacheList=eval_function((lisp_symbol *)cache_fun,call_with); 387 p_ref r1(CacheList); 388 389 if (CacheList && lcar(CacheList)) 390 { 391 void *obj_list=lcar(CacheList); 392 while (obj_list) 393 { 394 int t=lnumber_value(CAR(obj_list)); 395 if (t<0 || t>=total_objects) 396 lbreak("Get cache list returned a bad object number %d\n",t); 397 else 398 preload_cache_object(t); 399 obj_list=CDR(obj_list); 400 } 401 } 402 if (CacheList && lcdr(CacheList)) 403 { 404 void *id_list=lcar(lcdr(CacheList)); 405 while (id_list) 406 { 407 int id=lnumber_value(CAR(id_list)); 408 if (id<0 || id>=total) 409 lbreak("Get cache list returned a bad id number %d\n",id); 410 else if (list[id].last_access<0) 411 list[id].last_access=-2; 412 else list[id].last_access=2; 413 414 id_list=CDR(id_list); 415 } 416 } 417 current_space=sp; 418 418 419 419 } … … 443 443 if (id>=0 && id<nforetiles) 444 444 { 445 445 if (list[id].last_access<0) 446 446 list[id].last_access=-2; 447 else list[id].last_access=2; 448 } 449 } 447 else list[id].last_access=2; 448 } 449 } 450 450 } 451 451 … … 455 455 bg_line=lev->get_bgline(j); 456 456 for (i=0;i<lev->background_width();i++,bg_line++) 457 { 457 { 458 458 int id=backtiles[bgvalue(*bg_line)]; 459 459 if (id>=0 && id<nbacktiles) 460 460 { 461 461 if (list[id].last_access<0) 462 462 list[id].last_access=-2; 463 else list[id].last_access=2; 464 } 465 } 463 else list[id].last_access=2; 464 } 465 } 466 466 } 467 467 … … 491 491 int tnames=0; 492 492 int *fnum_remap; // remaps old filenumbers into current ones 493 493 494 494 tnames=fp->read_uint16(); 495 495 if (tnames) /// make sure there isn't bad info in the file 496 496 { 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 // search for a match 533 j=search(sorted_id_list,file_num,offset);534 535 {536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 // 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 // 579 // 580 581 582 583 584 585 586 587 588 589 590 591 592 } 593 594 595 596 597 598 } 599 } 497 fnum_remap=(int *)jmalloc(sizeof(int)*tnames,"pfname remap"); 498 499 int i; 500 for (i=0;i<tnames;i++) 501 { 502 fp->read(name,fp->read_uint8()); 503 fnum_remap[i]=-1; // initialize the map to no-map 504 505 int j; 506 for (j=0;j<crc_manager.total_filenames();j++) 507 if (!strcmp(crc_manager.get_filename(j),name)) 508 fnum_remap[i]=j; 509 } 510 511 uint32_t tsaved=fp->read_uint32(); 512 513 514 int *priority=(int *)jmalloc(tsaved*sizeof(int),"priorities"); 515 memset(priority,0xff,tsaved*sizeof(int)); // initialize to -1 516 int tmatches=0; 517 518 sorted_id_list=(int *)jmalloc(sizeof(int)*total,"sorted ids"); 519 for (j=0;j<total;j++) sorted_id_list[j]=j; 520 qsort(sorted_id_list,total,sizeof(int),s_offset_compare); 521 522 for (i=0;i<tsaved;i++) 523 { 524 uint8_t type=fp->read_uint8(); 525 short file_num=fp->read_uint16(); 526 if (file_num>=tnames) // bad data? 527 file_num=-1; 528 else file_num=fnum_remap[file_num]; 529 530 uint32_t offset=fp->read_uint32(); 531 532 // search for a match 533 j=search(sorted_id_list,file_num,offset); 534 if (j!=-1) 535 { 536 if (list[j].last_access<0) // if not loaded 537 list[j].last_access=-2; // mark as needing loading 538 else list[j].last_access=2; // mark as loaded and needing to stay that way 539 priority[i]=j; 540 tmatches++; 541 } 542 } 543 544 jfree(sorted_id_list); // was used for searching, no longer needed 545 546 for (j=0;j<total;j++) 547 if (list[j].last_access==0) 548 unmalloc(list+j); // free any cache entries that are not accessed at all in the level 549 550 551 ful=0; 552 int tcached=0; 553 for (j=0;j<total;j++) // now load all of the objects until full 554 { 555 // stat_man->update(j*70/total+25); 556 if (list[j].file_number>=0 && list[j].last_access==-2) 557 { 558 list[j].last_access=-1; 559 if (!ful) 560 { 561 switch (list[j].type) 562 { 563 case SPEC_BACKTILE : backt(j); break; 564 case SPEC_FORETILE : foret(j); break; 565 case SPEC_CHARACTER : 566 case SPEC_CHARACTER2 : fig(j); break; 567 case SPEC_IMAGE : img(j); break; 568 case SPEC_PARTICLE : part(j); break; 569 case SPEC_EXTERN_SFX : sfx(j); break; 570 case SPEC_EXTERNAL_LCACHE : lblock(j); break; 571 case SPEC_PALETTE : ctint(j); break; 572 } 573 tcached++; 574 } 575 } 576 } 577 load_fail=0; 578 // if (full()) 579 // dprintf("Cache filled while loading\n"); 580 581 if (tsaved>tmatches) 582 tmatches=tsaved+1; 583 584 last_access=tmatches+1; 585 for (i=0;i<tsaved;i++) // reorder the last access of each cache to reflect prioirties 586 { 587 if (priority[i]!=-1) 588 { 589 if (list[priority[i]].last_access!=-1) // make sure this wasn't the last item 590 list[priority[i]].last_access=tmatches--; 591 } 592 } 593 594 jfree(priority); 595 jfree(fnum_remap); 596 597 598 } 599 } 600 600 } 601 601 … … 609 609 if (list[j].file_number>=0 && list[j].last_access==-2) 610 610 { 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 611 list[j].last_access=-1; 612 if (!ful) 613 { 614 switch (list[j].type) 615 { 616 case SPEC_BACKTILE : backt(j); break; 617 case SPEC_FORETILE : foret(j); break; 618 case SPEC_CHARACTER : 619 case SPEC_CHARACTER2 : fig(j); break; 620 case SPEC_IMAGE : img(j); break; 621 case SPEC_PARTICLE : part(j); break; 622 case SPEC_EXTERN_SFX : sfx(j); break; 623 case SPEC_EXTERNAL_LCACHE : lblock(j); break; 624 case SPEC_PALETTE : ctint(j); break; 625 } 626 } 627 627 } 628 628 } … … 636 636 void CacheList::prof_poll_start() 637 637 { 638 poll_start_access=last_access; 638 poll_start_access=last_access; 639 639 } 640 640 … … 659 659 list[id].file_number=-1; 660 660 } 661 else 661 else 662 662 printf("Error : trying to unregister free object\n"); 663 663 } 664 664 665 665 static void cache_cleanup2() 666 { unlink(lfname); 666 { unlink(lfname); 667 667 } 668 668 669 669 static void cache_cleanup(int ret, void *arg) 670 { unlink(lfname); 670 { unlink(lfname); 671 671 } 672 672 … … 674 674 { 675 675 #ifdef WIN32 676 676 char *prefix="c:\\"; 677 677 #else 678 679 678 char const *prefix = "/tmp/"; // for UNIX store lisp cache in tmp dir 679 int flags = O_CREAT | O_RDWR; 680 680 #endif 681 681 682 683 684 685 682 int cfail = 1, num = 0; 683 do 684 { 685 sprintf(lfname,"%slcache%02d.tmp",prefix,num); 686 686 687 687 #if defined( __APPLE__ ) 688 689 690 691 692 693 694 688 unlink(lfname); 689 FILE *fp=fopen(lfname,"wb"); 690 if (fp) 691 { 692 fclose(fp); 693 cfail=0; 694 } 695 695 #else 696 697 696 int fd=open(lfname,flags,S_IRWXU | S_IRWXG | S_IRWXO); // can we get exclusive rights to this file? 697 if (fd<0) close(fd); else cfail=0; 698 698 #endif 699 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 700 if (cfail) 701 num++; 702 703 } while (cfail && num<15); 704 705 if (cfail) 706 { 707 fprintf(stderr,"Error : Unable to open cache file for compiled code.\n" 708 " Please delete all files named lcacheXX.tmp\n" 709 " and make sure you have write permission to\n" 710 " directory (%s)\n",prefix); 711 exit(0); 712 } 713 else 714 { 715 exit_proc(cache_cleanup,cache_cleanup2); // make sure this file gets deleted on exit.. 716 } 717 lcache_number=-1; 718 718 } 719 719 720 720 CacheList::CacheList() 721 721 { 722 // start out with a decent sized cache buffer because it's going to get allocated anyway. 723 total=0; 722 // start out with a decent sized cache buffer because it's going to get allocated anyway. 723 total=0; 724 724 list=NULL; 725 last_registered=-1; 726 cache_file=fp=NULL; 725 last_registered=-1; 726 cache_file=fp=NULL; 727 727 last_access=1; 728 728 used=ful=0; … … 735 735 736 736 CacheList::~CacheList() 737 { 737 { 738 738 } 739 739 … … 751 751 { 752 752 delete cache_file; 753 cache_file=NULL; 754 } 755 unlink(lfname); 753 cache_file=NULL; 754 } 755 unlink(lfname); 756 756 757 757 if (prof_data) … … 763 763 total=0; // reinitalize 764 764 list=NULL; 765 last_registered=-1; 766 cache_file=fp=NULL; 767 if (cache_read_file) 765 last_registered=-1; 766 cache_file=fp=NULL; 767 if (cache_read_file) 768 768 { 769 769 delete cache_read_file; … … 784 784 { 785 785 if (fp) delete fp; 786 if (last_dir) delete last_dir; 786 if (last_dir) delete last_dir; 787 787 if (local_only) 788 788 fp=new jFILE(crc_manager.get_filename(i->file_number),"rb"); … … 820 820 821 821 // see if we previously allocated an id, if so check the next spot in the array 822 // otherwise we will have to scan the whole list for a free id and possible 822 // otherwise we will have to scan the whole list for a free id and possible 823 823 // grow the list. 824 824 if (last_registered+1<total && list[last_registered+1].file_number<0) … … 841 841 { 842 842 list[total+i].file_number=-1; // mark new entries as new 843 844 843 list[total+i].last_access=-1; 844 list[total+i].data=NULL; 845 845 } 846 846 id=total; … … 857 857 858 858 int32_t CacheList::reg_lisp_block(Cell *block) 859 { 859 { 860 860 uint32_t s; 861 861 if (lcache_number==-1) … … 868 868 if (cache_read_file) 869 869 { 870 871 872 873 cache_file=new jFILE(lfname,"ab"); 874 } else cache_file=new jFILE(lfname,"wb"); 875 } 876 if (cache_file->open_failure()) 877 { 870 delete cache_read_file; 871 cache_read_file=NULL; 872 873 cache_file=new jFILE(lfname,"ab"); 874 } else cache_file=new jFILE(lfname,"wb"); // first time we opened 875 } 876 if (cache_file->open_failure()) 877 { 878 878 delete cache_file; 879 879 lprint(block); … … 889 889 ci->last_access=-1; 890 890 ci->type=SPEC_EXTERNAL_LCACHE; 891 if (!can_cache_lisp()) 891 if (!can_cache_lisp()) 892 892 { 893 893 ci->data=(void *)block; // we can't cache it out so it must be in memory 894 894 return id; 895 } 895 } 896 896 ci->data=NULL; // assume that it is in tmp memory, need to cache in on access 897 897 ci->offset=cache_file->tell(); … … 900 900 cache_file->write_uint32(s); 901 901 write_level(cache_file,block); 902 return id; 902 return id; 903 903 } 904 904 905 905 int32_t CacheList::reg_object(char const *filename, void *object, int type, int rm_dups) 906 { 906 { 907 907 char *name; 908 908 if (item_type(object)==L_CONS_CELL) // see if we got a object with a filename included … … 919 919 int32_t CacheList::reg(char const *filename, char const *name, int type, int rm_dups) 920 920 { 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 ci->type=se->type; 1000 return id; 921 int id=alloc_id(),i,fn=crc_manager.get_filenumber(filename); 922 CacheItem *ci=list+id; 923 CHECK(id<total && list[id].file_number<0); 924 925 if( type == SPEC_EXTERN_SFX ) // If a extern sound effect then just make sure it's there 926 { 927 bFILE *check=open_file(filename,"rb"); 928 if (check->open_failure()) 929 { 930 delete check; 931 if( sound_avail ) 932 { 933 printf("Unable to open file '%s' for reading\n",filename); 934 exit(0); 935 } 936 else 937 { 938 // Sound is disabled, we don't really care if the sound file 939 // is there or not, just pretend it's all ok. 940 return id; 941 } 942 } 943 char buf[4]; 944 check->read(buf,4); 945 delete check; 946 if (memcmp(buf,"RIFF",4)) 947 { 948 printf("File %s is not a WAV file\n",filename); 949 exit(0); 950 } 951 ci->file_number=fn; 952 ci->last_access=-1; 953 ci->data=NULL; 954 ci->offset=0; 955 ci->type=type; 956 return id; 957 } 958 959 spec_directory *sd=sd_cache.get_spec_directory(filename); 960 961 if (!sd) 962 { 963 printf("Unable to open filename %s for requested item %s\n",filename,name); 964 exit(0); 965 } 966 967 spec_entry *se; 968 if (type!=-1) 969 { 970 se=sd->find(name,type); 971 if (!se) se=sd->find(name); 972 } 973 else se=sd->find(name); 974 975 976 if (!se) 977 { 978 printf("No such item %s in file %s\n",name,filename); 979 exit(0); 980 } 981 else if (type>=0 && (type!=se->type && ((type!=SPEC_CHARACTER2 && type!=SPEC_CHARACTER) || 982 (se->type!=SPEC_CHARACTER && se->type!=SPEC_CHARACTER2)))) 983 { 984 printf("Item %s of file %s should be type %s\n",name,filename,spec_types[type]); 985 exit(0); 986 } 987 988 if (rm_dups) 989 { 990 for (i=0;i<total;i++) 991 if (list[i].file_number == fn && (unsigned)list[i].offset == se->offset) 992 return i; 993 } 994 995 ci->file_number=fn; 996 ci->last_access=-1; 997 ci->data=NULL; 998 ci->offset=se->offset; 999 ci->type=se->type; 1000 return id; 1001 1001 } 1002 1002 … … 1022 1022 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1023 1023 1024 if (me->last_access>=0) 1024 if (me->last_access>=0) 1025 1025 { 1026 1026 touch(me); … … 1036 1036 last_offset=fp->tell(); 1037 1037 return (backtile *)me->data; 1038 } 1038 } 1039 1039 } 1040 1040 … … 1045 1045 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1046 1046 1047 if (me->last_access>=0) 1047 if (me->last_access>=0) 1048 1048 { 1049 1049 touch(me); … … 1059 1059 last_offset=fp->tell(); 1060 1060 return (foretile *)me->data; 1061 } 1061 } 1062 1062 } 1063 1063 … … 1066 1066 CacheItem *me=list+id; 1067 1067 // CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1068 if (me->last_access>=0) 1068 if (me->last_access>=0) 1069 1069 { 1070 1070 touch(me); … … 1080 1080 last_offset=fp->tell(); 1081 1081 return (figure *)me->data; 1082 } 1082 } 1083 1083 } 1084 1084 … … 1087 1087 CacheItem *me=list+id; 1088 1088 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1089 if (me->last_access>=0) 1089 if (me->last_access>=0) 1090 1090 { 1091 1091 touch(me); … … 1103 1103 1104 1104 return (image *)me->data; 1105 } 1105 } 1106 1106 } 1107 1107 … … 1110 1110 CacheItem *me=list+id; 1111 1111 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1112 if (me->last_access>=0) 1112 if (me->last_access>=0) 1113 1113 { 1114 1114 touch(me); // hold me, feel me, be me! … … 1123 1123 alloc_space=sp; 1124 1124 return (sound_effect *)me->data; 1125 } 1125 } 1126 1126 } 1127 1127 … … 1131 1131 CacheItem *me=list+id; 1132 1132 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1133 if (me->last_access>=0) 1133 if (me->last_access>=0) 1134 1134 { 1135 1135 touch(me); // hold me, feel me, be me! … … 1145 1145 last_offset=fp->tell(); 1146 1146 return (part_frame *)me->data; 1147 } 1147 } 1148 1148 } 1149 1149 … … 1154 1154 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1155 1155 if (!can_cache_lisp()) return (Cell *)me->data; 1156 if (me->last_access>=0) 1156 if (me->last_access>=0) 1157 1157 { 1158 1158 touch(me); … … 1165 1165 delete cache_file; 1166 1166 cache_file=NULL; 1167 } 1167 } 1168 1168 touch(me); 1169 1169 … … 1171 1171 { 1172 1172 cache_read_file=new jFILE(crc_manager.get_filename(me->file_number),"rb"); 1173 1173 1174 1174 int cache_size=80*1024; // 80K 1175 cache_read_file->set_read_buffer_size(cache_size); 1175 cache_read_file->set_read_buffer_size(cache_size); 1176 1176 uint8_t mini_buf; 1177 1177 cache_read_file->read(&mini_buf,1); // prime the buffer … … 1190 1190 1191 1191 int cs=current_space; 1192 use_user_space(space,size); 1192 use_user_space(space,size); 1193 1193 load_block(cache_read_file); 1194 1194 current_space=cs; 1195 1195 1196 1196 alloc_space=sp; 1197 1197 if (size) … … 1199 1199 else me->data=NULL; 1200 1200 return (Cell *)me->data; 1201 } 1201 } 1202 1202 } 1203 1203 … … 1226 1226 { 1227 1227 dprintf("mem_maker : freeing %s\n",spec_types[oldest->type]); 1228 unmalloc(oldest); 1228 unmalloc(oldest); 1229 1229 } 1230 1230 else … … 1234 1234 mem_report("out_of_mem"); 1235 1235 exit(0); 1236 } 1236 } 1237 1237 } 1238 1238 … … 1242 1242 int old=last_access,new_old_accessed; 1243 1243 CacheItem *ci,*new_old; 1244 1244 1245 1245 do 1246 1246 { … … 1248 1248 new_old=NULL; 1249 1249 ci=list; 1250 for (int i=0;i<total;i++,ci++) 1251 { 1252 if (ci->last_access<old && ci->last_access>0 && ci->last_access>new_old_accessed) 1253 { 1254 1255 new_old=ci; 1250 for (int i=0;i<total;i++,ci++) 1251 { 1252 if (ci->last_access<old && ci->last_access>0 && ci->last_access>new_old_accessed) 1253 { 1254 new_old_accessed=ci->last_access; 1255 new_old=ci; 1256 1256 } 1257 1257 } … … 1261 1261 old=ci->last_access; 1262 1262 printf("type=(%20s) file=(%20s) access=(%6ld)\n",spec_types[ci->type], 1263 1264 1263 crc_manager.get_filename(ci->file_number), 1264 (long int)ci->last_access); 1265 1265 } 1266 1266 } while (new_old); … … 1272 1272 CacheItem *me=list+id; 1273 1273 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); 1274 if (me->last_access>=0) 1274 if (me->last_access>=0) 1275 1275 return 1; 1276 1276 else return 0; … … 1283 1283 CacheItem *me=list+id; 1284 1284 CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id" && me->type==SPEC_PALETTE); 1285 if (me->last_access>=0) 1285 if (me->last_access>=0) 1286 1286 { 1287 1287 touch(me); … … 1297 1297 last_offset=fp->tell(); 1298 1298 return (char_tint *)me->data; 1299 } 1300 } 1301 1302 1303 1304 1299 } 1300 } 1301 1302 1303 1304 -
abuse/trunk/src/cache.hpp
r123 r124 70 70 protected: 71 71 void *data; 72 int32_t last_access; 72 int32_t last_access; 73 73 uint8_t type; 74 74 int16_t file_number; -
abuse/trunk/src/calctrig.cpp
r56 r124 25 25 26 26 printf("uint16_t atan_table[1662]={\n "); 27 27 28 28 for (i=1;i<1662;i++) 29 { 29 { 30 30 if (i<29) x=0; 31 31 else x=(long)(atan(i/(double)29)/3.14152654*180)-45; … … 35 35 if ((i%12)==11) printf("\n "); 36 36 } 37 printf("};\n"); 37 printf("};\n"); 38 38 } -
abuse/trunk/src/chars.cpp
r123 r124 42 42 }; 43 43 44 /* 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 44 /* "start_still_jump","still_jump","still_jump_fall","end_still_jump", 45 46 "morph_pose", 47 48 "walking", 49 50 51 "weapon_draw", 52 "weapon_put_away", 53 "weapon_fire", 54 "weapon_end_fire", 55 "weapon_fire_up", 56 "weapon_end_fire_up", 57 58 "blocking", 59 "block_recoil", 60 61 "turn_around", 62 "flinch_up","flinch_down","flinch_back", 63 "flinch_air","flinch_ground","flinch_getup","woze", 64 "stance" 65 } ; */ 66 66 67 67 … … 104 104 } 105 105 num=lnumber_value(val); 106 } else 106 } else 107 107 { 108 108 num=ts; … … 118 118 lprint(symbol); 119 119 lbreak("symbol has been assigned value %d, but value already in use by state %s\n" 120 121 120 "use a different symbol for this state\n", 121 lstring_value(symbol_name(seq_syms[num]))); 122 122 exit(0); 123 123 } else if (num>=ts) 124 124 { 125 seq=(sequence **)jrealloc(seq,sizeof(sequence *)*(num+1),"state list"); 126 seq_syms=(void **)jrealloc(seq_syms,sizeof(void *)*(num+1),"state sym list"); 125 seq=(sequence **)jrealloc(seq,sizeof(sequence *)*(num+1),"state list"); 126 seq_syms=(void **)jrealloc(seq_syms,sizeof(void *)*(num+1),"state sym list"); 127 127 128 128 memset(&seq[ts],0,sizeof(sequence *)*((num+1)-ts)); … … 162 162 if (seq[which]) 163 163 delete seq[which]; 164 seq[which]=new_seq; 165 } 164 seq[which]=new_seq; 165 } 166 166 167 167 void *l_obj_get(long number) // exten lisp function switches on number … … 173 173 return 0; 174 174 } 175 return new_lisp_number(current_object->lvars[t->var_index[number]]); 175 return new_lisp_number(current_object->lvars[t->var_index[number]]); 176 176 } 177 177 … … 195 195 return; 196 196 } 197 dprintf("%d",current_object->lvars[t->var_index[number]]); 197 dprintf("%d",current_object->lvars[t->var_index[number]]); 198 198 } 199 199 … … 214 214 { 215 215 if (vars[index]) 216 { 217 218 219 220 221 222 223 224 225 226 227 228 229 } else 230 { 231 232 233 216 { 217 lbreak("While defining object %s :\n" 218 " var '%s' was previously defined by another\n" 219 " with index %d, but %s has a var listed '%s' with same index\n" 220 " try moving definition of %s before previously declared object", 221 lstring_value(symbol_name(name)), 222 lstring_value(symbol_name(symbol)), 223 index, 224 lstring_value(symbol_name(name)), 225 lstring_value(symbol_name(vars[index])), 226 lstring_value(symbol_name(name)) 227 ); 228 exit(0); 229 } else 230 { 231 var_index[index]=tv; 232 vars[index]=symbol; 233 tv++; 234 234 } 235 235 } else … … 245 245 vars[index]=symbol; 246 246 tv++; 247 } 247 } 248 248 } else /** Nope, looks like we have to add the variable ourself and define the assesor funs */ 249 249 { … … 267 267 268 268 add_c_object(symbol,free_index); 269 269 270 270 vars[free_index]=symbol; 271 271 var_index[free_index]=tv; … … 285 285 } 286 286 for (i=0;i<tiv;i++) 287 if (!strcmp(lstring_value(symbol_name(vars[i])),name)) 287 if (!strcmp(lstring_value(symbol_name(vars[i])),name)) 288 288 return 1; 289 289 return 0; 290 290 } 291 291 292 character_type::character_type(void *args, void *name) 292 character_type::character_type(void *args, void *name) 293 293 { 294 294 p_ref r2(args); … … 322 322 323 323 for (i=0;i<TOTAL_ABILITIES;i++) 324 abil[i]=get_ability_default((ability)i); 324 abil[i]=get_ability_default((ability)i); 325 325 void *field=args; 326 326 p_ref r7(field); … … 329 329 void *f=CAR(CAR(field)); 330 330 p_ref r1(f); 331 331 332 332 if (f==l_abil) 333 333 { … … 336 336 for (i=0;i<TOTAL_ABILITIES;i++) 337 337 { 338 339 340 341 338 Cell *ab=assoc(make_find_symbol(ability_names[i]),l); 339 p_ref r5(ab); 340 if (!NILP(ab)) 341 abil[i]=lnumber_value(eval(lcar(lcdr(ab)))); 342 342 } 343 343 } else if (f==l_funs) … … 347 347 for (i=0;i<TOTAL_OFUNS;i++) 348 348 { 349 350 351 352 349 Cell *ab=assoc(make_find_symbol(ofun_names[i]),l); 350 p_ref r5(ab); 351 if (!NILP(ab) && lcar(lcdr(ab))) 352 fun_table[i]=lcar(lcdr(ab)); 353 353 } 354 354 } else if (f==l_flags) … … 358 358 for (i=0;i<TOTAL_CFLAGS;i++) 359 359 { 360 361 362 363 364 } 365 360 Cell *ab=assoc(make_find_symbol(cflag_names[i]),l); 361 p_ref r5(ab); 362 if (!NILP(ab) && eval(lcar(lcdr(ab)))) 363 cflags|=(1<<i); 364 } 365 366 366 if (get_cflag(CFLAG_IS_WEAPON)) // if this is a weapon add to weapon array 367 367 { 368 369 370 368 total_weapons++; 369 weapon_types=(int *)jrealloc(weapon_types,sizeof(int)*total_weapons,"weapon map"); 370 weapon_types[total_weapons-1]=total_objects; 371 371 } 372 372 } else if (f==l_range) … … 386 386 while (l) 387 387 { 388 389 390 391 392 393 394 395 396 } 388 int index; 389 void *e; 390 sequence *mem; 391 index = add_state(CAR((CAR(l)))); 392 e = eval(CAR(CDR(CAR(l)))); 393 mem = new sequence(fn,e,NULL); 394 seq[index]=mem; 395 l=CDR(l); 396 } 397 397 } else if (f==l_fields) 398 398 { … … 401 401 while (!NILP(mf)) 402 402 { 403 404 char *fake=lstring_value(eval(lcar(lcdr(lcar(mf))))); 405 406 407 408 409 410 } 411 412 413 414 415 403 char *real=lstring_value(eval(lcar(lcar(mf)))); 404 char *fake=lstring_value(eval(lcar(lcdr(lcar(mf))))); 405 if (!isa_var_name(real)) 406 { 407 lprint(field); 408 lbreak("fields : no such var name \"%s\"\n",name); 409 exit(0); 410 } 411 total_fields++; 412 413 fields=(named_field **)jrealloc(fields,sizeof(named_field *)*total_fields,"named_fields"); 414 fields[total_fields-1]=new named_field(real,fake); 415 mf=lcdr(mf); 416 416 } 417 417 } else if (f==l_logo) … … 426 426 while (l) 427 427 { 428 429 430 } 428 add_var(CAR(l),name); 429 l=CDR(l); 430 } 431 431 } 432 432 else … … 435 435 lbreak("Unknown field for character definition"); 436 436 exit(0); 437 } 437 } 438 438 } 439 439 440 440 if (!seq[stopped]) 441 441 lbreak("object (%s) has no stopped state, please define one!\n", 442 442 lstring_value(symbol_name(name))); 443 443 444 444 /* char *fn=lstring_value(lcar(desc)); … … 465 465 printf("missing state state art in def-character (%s)\n",name); 466 466 exit(0); 467 } 468 467 } 468 469 469 sa=lcdr(sa); // list of state sequences 470 470 while (!NILP(sa)) 471 471 { 472 472 int num=lnumber_value(lcar(lcar(sa))); 473 if (seq[num]) 473 if (seq[num]) 474 474 printf("Warning : state '%s' defined multiply for object %s\n" 475 476 else 475 " using first definition\n",state_names[num],name); 476 else 477 477 seq[lnumber_value(lcar(lcar(sa)))]=new sequence(fn,lcar(lcdr(lcar(sa))),lcar(lcdr(lcdr(lcar(sa))))); 478 sa=lcdr(sa); 478 sa=lcdr(sa); 479 479 } 480 480 … … 483 483 { 484 484 rangex=lnumber_value(lcar(lcdr(range))); 485 rangey=lnumber_value(lcar(lcdr(lcdr(range)))); 486 } else 485 rangey=lnumber_value(lcar(lcdr(lcdr(range)))); 486 } else 487 487 { 488 488 rangex=100; … … 504 504 for (int i=0;find<0 && i<t;i++) 505 505 if (!strcmp(default_simple.var_name(i),name)) 506 506 find=i; 507 507 if (find<0) 508 508 { 509 510 511 512 513 514 515 } 509 lprint(assoc(l_fields,desc)); 510 printf("fields : no such var name \"%s\"\n",name); 511 printf("current possiblities are : \n"); 512 for (int i=0;i<t;i++) printf("\"%s\" ",default_simple.var_name(i)); 513 printf("\n"); 514 exit(0); 515 } 516 516 char *new_name=lstring_value(lcar(lcdr(lcar(mf)))); 517 517 total_fields++; … … 525 525 526 526 Cell *lg=assoc(l_logo,desc); 527 if (NILP(lg)) 527 if (NILP(lg)) 528 528 { 529 529 if (get_cflag(CFLAG_IS_WEAPON)) … … 531 531 lprint(desc); 532 532 lbreak("object must have a logo defined if it is a weapon\n" 533 533 "example '(logo . (""art/misc.spe"" . ""big waepon""))\n"); 534 534 } 535 535 logo=-1; 536 536 } 537 else 538 logo=cache.reg_object(fn,lcdr(lg),SPEC_IMAGE,1); 537 else 538 logo=cache.reg_object(fn,lcdr(lg),SPEC_IMAGE,1); 539 539 */ 540 540 } … … 551 551 character_type::~character_type() 552 552 { 553 for (int i=0;i<ts;i++) 554 if (seq[i]) 553 for (int i=0;i<ts;i++) 554 if (seq[i]) 555 555 delete seq[i]; 556 556 if (ts) jfree(seq); … … 565 565 if (ts) 566 566 jfree(seq_syms); 567 567 568 568 if (tiv) 569 569 { -
abuse/trunk/src/chars.hpp
r66 r124 21 21 22 22 23 enum character_state {dead, 24 25 stopped,26 27 28 29 30 23 enum character_state {dead, 24 dieing, 25 stopped, 26 start_run_jump,run_jump, run_jump_fall, end_run_jump, 27 flinch_up,flinch_down, 28 morph_pose, 29 running 30 } ; 31 31 32 32 … … 40 40 char *real_name; 41 41 char *descript_name; 42 named_field(char *real, char *fake) 43 { real_name=strcpy((char *)jmalloc(strlen(real)+1,"var_name"),real); 44 descript_name=strcpy((char *)jmalloc(strlen(fake)+1,"var_name"),fake); 42 named_field(char *real, char *fake) 43 { real_name=strcpy((char *)jmalloc(strlen(real)+1,"var_name"),real); 44 descript_name=strcpy((char *)jmalloc(strlen(fake)+1,"var_name"),fake); 45 45 } 46 46 ~named_field() { jfree(real_name); jfree(descript_name); } … … 61 61 CFLAG_CACHED_IN, 62 62 CFLAG_NEED_CACHE_IN, 63 CFLAG_UNACTIVE_SHIELD // if object is not active (i.e. link 0 aistate==0) 63 CFLAG_UNACTIVE_SHIELD // if object is not active (i.e. link 0 aistate==0) 64 64 // then objects will not draw a damage when hitting it 65 65 }; … … 72 72 OFUN_DRAW, 73 73 OFUN_MAP_DRAW, 74 OFUN_DAMAGE, // called when the object receives damage 74 OFUN_DAMAGE, // called when the object receives damage 75 75 OFUN_NEXT_STATE, // called at the end of an object sequence 76 76 OFUN_USER_FUN, // can by called (user_fun x y z) … … 84 84 85 85 class character_type 86 { 86 { 87 87 public : 88 88 ushort ts,tiv,tv; // total states, total index vars, total local vars … … 97 97 int abil[TOTAL_ABILITIES]; 98 98 void *fun_table[TOTAL_OFUNS]; // pointers to lisp function for this object 99 int logo,morph_mask,morph_power; 99 int logo,morph_mask,morph_power; 100 100 long rangex,rangey,draw_rangex,draw_rangey; // range off screen before character is skipped 101 101 … … 104 104 int get_cflag(int name) { return cflags&(1<<name); } 105 105 void set_cflag(int name, int x) { if (x) cflags|=(1<<name); else cflags&=~(1<<name); } 106 int total_fields; // used by game editor to replace field names 106 int total_fields; // used by game editor to replace field names 107 107 named_field **fields; 108 character_type(void *args, void *name); // lisp object describes object 108 character_type(void *args, void *name); // lisp object describes object 109 109 110 110 sequence *get_sequence(character_state s); 111 void add_sequence(character_state which, sequence *new_seq); 111 void add_sequence(character_state which, sequence *new_seq); 112 112 int has_sequence(character_state s) { return s<ts && (seq[s]!=NULL); } 113 113 int cache_in(); // returns false if out of cache memory -
abuse/trunk/src/chat.cpp
r111 r124 36 36 { 37 37 memmove(screen,screen+w,w*(h-3)); 38 memset(screen+w*(h-3),' ',w); 38 memset(screen+w*(h-3),' ',w); 39 39 memcpy(screen+w*(h-3),st,strlen(st)); 40 40 redraw(); -
abuse/trunk/src/chat.hpp
r106 r124 22 22 void clear(); 23 23 chat_console(JCFont *font, int width, int height); 24 24 25 25 } ; 26 26 -
abuse/trunk/src/client.hpp
r57 r124 17 17 - Send current inputs 18 18 19 - read server commands until 19 - read server commands until 20 20 - process commands 21 21 - ability to detach from server 22 22 - ability to "talk" with a local server 23 23 through global local_server 24 25 24 and functions local_server->insert_received_packet(pk); 25 local_server->get_output_packet(pk); 26 26 27 27 -
abuse/trunk/src/clisp.cpp
r123 r124 48 48 *l_sneaky_image,*l_draw_fast,*l_player_tints,*l_save_order,*l_next_song, 49 49 *l_level_load_start, 50 *l_level_load_end, 50 *l_level_load_end, *l_cdc_logo, 51 51 *l_keep_backup, 52 52 *l_switch_to_powerful, … … 66 66 void *l_statbar_ammo_x,*l_statbar_ammo_y, 67 67 *l_statbar_ammo_w,*l_statbar_ammo_h, 68 68 *l_statbar_ammo_bg_color, 69 69 70 70 *l_statbar_health_x,*l_statbar_health_y, 71 71 *l_statbar_health_w,*l_statbar_health_h, 72 73 74 75 uint8_t chatting_enabled=0; 72 *l_statbar_health_bg_color, 73 74 *l_statbar_logo_x,*l_statbar_logo_y; 75 uint8_t chatting_enabled=0; 76 76 77 77 extern void scatter_line(int x1, int y1, int x2, int y2, int c, int s); … … 189 189 set_symbol_number(make_find_symbol(cflag_names[i]),i); 190 190 191 l_song_list=make_find_symbol("song_list"); 191 l_song_list=make_find_symbol("song_list"); 192 192 l_post_render=make_find_symbol("post_render"); 193 193 … … 224 224 add_c_function("y",0,0, 31); 225 225 add_c_bool_fun("set_x",1,1, 32); 226 add_c_bool_fun("set_y",1,1, 33); 226 add_c_bool_fun("set_y",1,1, 33); 227 227 add_c_bool_fun("push_characters",2,2, 34); 228 228 … … 252 252 add_c_bool_fun("freeze_player",1,1, 58); // freeze time 253 253 254 add_c_function("menu",1,-1, 59); 254 add_c_function("menu",1,-1, 59); 255 255 add_c_bool_fun("do_command",1,1, 60); // command string 256 256 add_c_bool_fun("set_game_state",1,1, 61); 257 257 258 258 259 259 // scene control functions, game must first be set to scene mode. … … 285 285 add_c_function("morph_detail",0,0, 89); 286 286 add_c_bool_fun("morph_into",3,3, 90); // type aneal frames 287 add_c_bool_fun("link_object",1,1, 91); 288 289 add_c_bool_fun("draw_line",5,5, 92); 290 add_c_function("dark_color",0,0, 93); 291 add_c_function("medium_color",0,0, 94); 292 add_c_function("bright_color",0,0, 95); 293 294 add_c_bool_fun("remove_object",1,1, 99); 295 add_c_bool_fun("link_light",1,1, 100); 296 add_c_bool_fun("remove_light",1,1, 101); 297 add_c_function("total_objects",0,0, 102); 298 add_c_function("total_lights",0,0, 103); 287 add_c_bool_fun("link_object",1,1, 91); 288 289 add_c_bool_fun("draw_line",5,5, 92); 290 add_c_function("dark_color",0,0, 93); 291 add_c_function("medium_color",0,0, 94); 292 add_c_function("bright_color",0,0, 95); 293 294 add_c_bool_fun("remove_object",1,1, 99); 295 add_c_bool_fun("link_light",1,1, 100); 296 add_c_bool_fun("remove_light",1,1, 101); 297 add_c_function("total_objects",0,0, 102); 298 add_c_function("total_lights",0,0, 103); 299 299 300 300 add_c_bool_fun("set_light_r1",2,2, 104); … … 314 314 add_c_function("xacel",0,0, 116); 315 315 add_c_function("yacel",0,0, 117); 316 add_c_bool_fun("delete_light",1,1, 118); 316 add_c_bool_fun("delete_light",1,1, 118); 317 317 318 318 add_c_bool_fun("set_fx",1,1, 119); … … 336 336 add_c_bool_fun("hurt_radius",6,6, 143); // x y radius max_damage exclude_object max_push 337 337 338 add_c_bool_fun("add_ammo",2,2, 144); // weapon_type, amount 338 add_c_bool_fun("add_ammo",2,2, 144); // weapon_type, amount 339 339 add_c_function("ammo_total",1,1, 145); // returns total for type weapon 340 340 add_c_function("current_weapon",0,0, 146); // weapon_type, amount … … 349 349 add_c_bool_fun("set_course",2,2, 154); // angle, magnitude 350 350 add_c_bool_fun("set_frame_angle",3,3, 155); // ang1,ang2, ang 351 add_c_bool_fun("jump_state",1,1, 156); // don't reset current_frame 351 add_c_bool_fun("jump_state",1,1, 156); // don't reset current_frame 352 352 353 353 add_c_bool_fun("morphing",0,0, 168); … … 369 369 add_c_bool_fun("set_otype",1,1, 182); // otype 370 370 371 add_c_function("current_frame",0,0, 184); 371 add_c_function("current_frame",0,0, 184); 372 372 add_c_function("fx",0,0, 185); 373 373 add_c_function("fy",0,0, 186); … … 391 391 add_c_function("load_small_font",2,2, 204); // filename, name 392 392 add_c_function("load_console_font",2,2, 205); // filename, name 393 add_c_function("set_current_frame",1,1, 206); 393 add_c_function("set_current_frame",1,1, 206); 394 394 395 395 add_c_bool_fun("draw_transparent",2,2, 208); // count, max … … 415 415 add_c_function("def_tint",1,1, 227); // filename 416 416 add_c_function("tint_palette",3,3, 228); // radd,gadd,badd 417 add_c_function("player_number",0,0, 229); 417 add_c_function("player_number",0,0, 229); 418 418 add_c_bool_fun("set_current_weapon",1,1, 230); // type 419 419 add_c_bool_fun("has_weapon",1,1, 231); // type … … 482 482 add_c_bool_fun("demo_break_enable",0,0, 291); 483 483 add_c_bool_fun("am_a_client",0,0, 292); 484 add_c_bool_fun("time_for_next_level",0,0, 293); 484 add_c_bool_fun("time_for_next_level",0,0, 293); 485 485 add_c_bool_fun("reset_kills",0,0, 294); 486 486 add_c_bool_fun("set_game_name",1,1, 295); // name 487 add_c_bool_fun("set_net_min_players",1,1, 296); 488 487 add_c_bool_fun("set_net_min_players",1,1, 296); 488 489 489 490 490 add_lisp_function("go_state",1,1, 0); … … 494 494 add_lisp_function("bg",0,0, 4); 495 495 add_lisp_function("find_closest",1,1, 5); 496 add_lisp_function("find_xclosest",1,1, 6); 497 add_lisp_function("find_xrange",2,2, 7); 496 add_lisp_function("find_xclosest",1,1, 6); 497 add_lisp_function("find_xrange",2,2, 7); 498 498 add_lisp_function("add_object",3,4, 8); // type, x,y (type) 499 499 add_lisp_function("first_focus",0,0, 9); … … 554 554 555 555 add_lisp_function("score_draw",0,0, 61); 556 add_lisp_function("show_kills",0,0, 62); 557 add_lisp_function("mkptr",1,1, 63); 556 add_lisp_function("show_kills",0,0, 62); 557 add_lisp_function("mkptr",1,1, 63); 558 558 add_lisp_function("seq",3,3, 64); 559 559 } … … 566 566 switch (number) 567 567 { 568 case 0 : 569 { 570 current_object->set_aistate(lnumber_value(eval(CAR(args)))); 568 case 0 : 569 { 570 current_object->set_aistate(lnumber_value(eval(CAR(args)))); 571 571 current_object->set_aistate_time(0); 572 572 void *ai=figures[current_object->otype]->get_fun(OFUN_AI); 573 573 if (!ai) 574 574 { 575 576 577 575 lbreak("hrump... call to go_state, and no ai function defined?\n" 576 "Are you calling from move function (not mover)?\n"); 577 exit(0); 578 578 } 579 579 return eval_function((lisp_symbol *)ai,NULL); … … 582 582 { 583 583 game_object *old_cur=current_object; 584 current_object=(game_object *)lpointer_value(eval(CAR(args))); 584 current_object=(game_object *)lpointer_value(eval(CAR(args))); 585 585 void *ret=eval_block(CDR(args)); 586 586 current_object=old_cur; … … 604 604 605 605 case 3 : return new_lisp_pointer(current_object); break; 606 case 4 : 606 case 4 : 607 607 { if (player_list->next) 608 608 return new_lisp_pointer(current_level->attacker(current_object)); 609 609 else return new_lisp_pointer(player_list->focus); } break; 610 610 case 5 : return new_lisp_pointer(current_level->find_closest(current_object->x, 611 612 613 611 current_object->y, 612 lnumber_value(eval(CAR(args))), 613 current_object)); break; 614 614 case 6 : return new_lisp_pointer(current_level->find_xclosest(current_object->x, 615 616 617 618 619 case 7 : 615 current_object->y, 616 lnumber_value(eval(CAR(args))), 617 current_object 618 )); break; 619 case 7 : 620 620 { 621 621 long n1=lnumber_value(eval(CAR(args))); 622 622 long n2=lnumber_value(eval(CAR(CDR(args)))); 623 623 return new_lisp_pointer(current_level->find_xrange(current_object->x, 624 625 626 627 628 } break; 629 case 8 : 624 current_object->y, 625 n1, 626 n2 627 )); 628 } break; 629 case 8 : 630 630 { 631 631 int type=lnumber_value(eval(CAR(args))); args=CDR(args); … … 641 641 return new_lisp_pointer(o); 642 642 } break; 643 case 22 : 643 case 22 : 644 644 { 645 645 int type=lnumber_value(eval(CAR(args))); args=CDR(args); … … 657 657 658 658 case 9 : return new_lisp_pointer(the_game->first_view->focus); break; 659 case 10 : 659 case 10 : 660 660 { 661 661 view *v=((game_object *)lpointer_value(eval(CAR(args))))->controller()->next; … … 664 664 else return NULL; 665 665 } break; 666 case 11 : 667 { 666 case 11 : 667 { 668 668 return new_lisp_pointer 669 669 ((void *)current_object->get_object(lnumber_value(eval(CAR(args))))); 670 670 } break; 671 case 12 : 672 { 671 case 12 : 672 { 673 673 return new_lisp_pointer 674 674 ((void *)current_object->get_light(lnumber_value(eval(CAR(args))))); … … 679 679 void *ret=NULL; 680 680 for (int i=0;i<old_cur->total_objects();i++) 681 { 682 683 681 { 682 current_object=old_cur->get_object(i); 683 ret=eval(CAR(args)); 684 684 } 685 685 current_object=old_cur; … … 705 705 void *f=figures[current_object->otype]->get_fun(OFUN_USER_FUN); 706 706 if (!f) return NULL; 707 return eval_function((lisp_symbol *)f,args); 707 return eval_function((lisp_symbol *)f,args); 708 708 } break; 709 709 case 17 : … … 714 714 for (int x=0;x<trials;x++) 715 715 { 716 717 716 clear_tmp(); 717 eval(CAR(args)); 718 718 } 719 719 time_marker end; … … 733 733 void *list=eval(CAR(args)); 734 734 game_object *find=current_level->find_object_in_area(current_object->x, 735 736 737 if (find) return new_lisp_pointer(find); 735 current_object->y, 736 x1,y1,x2,y2,list,current_object); 737 if (find) return new_lisp_pointer(find); 738 738 else return NULL; 739 739 } break; … … 747 747 p_ref r1(list); 748 748 game_object *find=current_level->find_object_in_angle(current_object->x, 749 750 751 if (find) return new_lisp_pointer(find); 749 current_object->y, 750 a1,a2,list,current_object); 751 if (find) return new_lisp_pointer(find); 752 752 else return NULL; 753 753 } break; … … 757 757 if (item_type(sym)!=L_SYMBOL) 758 758 { 759 760 759 lbreak("expecting first arg to def-character to be a symbol!\n"); 760 exit(0); 761 761 } 762 762 int sp=current_space; … … 767 767 { 768 768 object_names=(char **)jmalloc(sizeof(char *)*(total_objects+1),"object name list"); 769 769 figures=(character_type **)jmalloc(sizeof(character_type *)*(total_objects+1),"character types"); 770 770 } 771 771 else 772 772 { 773 773 object_names=(char **)jrealloc(object_names,sizeof(char *)*(total_objects+1), 774 775 776 774 "object name list"); 775 figures=(character_type **)jrealloc(figures,sizeof(character_type *)*(total_objects+1), 776 "character types"); 777 777 } 778 778 779 779 object_names[total_objects]=strcpy( 780 781 780 (char *)jmalloc(strlen(lstring_value(symbol_name(sym)))+1,"object name"), 781 lstring_value(symbol_name(sym))); 782 782 figures[total_objects]=new character_type(CDR(args),sym); 783 783 total_objects++; … … 823 823 case 36 : 824 824 { 825 825 826 826 int32_t xm,ym,but; 827 827 xm=lnumber_value(CAR(args)); args=CDR(args); … … 889 889 void *ret=NULL; 890 890 { 891 892 893 894 895 896 891 p_ref r1(ret); 892 push_onto_list(new_lisp_number((last_demo_mbut&4)==4),ret); 893 push_onto_list(new_lisp_number((last_demo_mbut&2)==2),ret); 894 push_onto_list(new_lisp_number((last_demo_mbut&1)==1),ret); 895 push_onto_list(new_lisp_number(last_demo_my),ret); 896 push_onto_list(new_lisp_number(last_demo_mx),ret); 897 897 } 898 898 return ret; … … 907 907 void *ret=NULL; 908 908 { 909 910 911 909 p_ref r1(ret); 910 push_onto_list(new_lisp_number(ry),ret); 911 push_onto_list(new_lisp_number(rx),ret); 912 912 } 913 913 return ret; … … 922 922 void *ret=NULL; 923 923 { 924 925 926 924 p_ref r1(ret); 925 push_onto_list(new_lisp_number(ry),ret); 926 push_onto_list(new_lisp_number(rx),ret); 927 927 } 928 928 return ret; 929 929 } break; 930 930 case 51 : return new_lisp_pointer(wm->font()); break; 931 case 52 : 931 case 52 : 932 932 { 933 933 view *c=current_object->controller(); … … 958 958 char tmp[200]; 959 959 { 960 961 962 963 964 965 966 967 968 if (*s=='/' || *s=='\\') 969 970 971 972 960 p_ref r1(fn); 961 char *slash=lstring_value(eval(CAR(args))); 962 char *filename=lstring_value(fn); 963 964 char *s=filename,*tp; 965 966 for (tp=tmp;*s;s++,tp++) 967 { 968 if (*s=='/' || *s=='\\') 969 *tp=*slash; 970 else *tp=*s; 971 } 972 *tp=0; 973 973 } 974 974 return new_lisp_string(tmp); … … 986 986 void *fl=NULL,*dl=NULL,*rl=NULL; 987 987 { 988 989 990 991 992 993 994 995 996 997 998 } 999 988 p_ref r1(fl),r2(dl); 989 990 for (i=tfiles-1;i>=0;i--) { push_onto_list(new_lisp_string(files[i]),fl); jfree(files[i]); } 991 jfree(files); 992 993 for (i=tdirs-1;i>=0;i--) { push_onto_list(new_lisp_string(dirs[i]),dl); jfree(dirs[i]); } 994 jfree(dirs); 995 996 push_onto_list(dl,rl); 997 push_onto_list(fl,rl); 998 } 999 1000 1000 return rl; 1001 1001 } break; … … 1007 1007 case 61 : return score_draw(); break; 1008 1008 case 62 : return show_kills(); break; 1009 case 63 : 1010 { 1011 1012 1013 1009 case 63 : 1010 { 1011 long x; 1012 sscanf(lstring_value(eval(CAR(args))),"%lx",&x); 1013 return new_lisp_pointer((void *)(intptr_t)x); 1014 1014 } break; 1015 1015 case 64 : … … 1037 1037 push_onto_list(new_lisp_string(name2),ret); 1038 1038 } 1039 } 1039 } 1040 1040 return ret; 1041 1041 } … … 1049 1049 long c_caller(long number, void *args) 1050 1050 { 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 current_object->set_aistate_time(0); 1095 current_object->set_aistate(ns); return 1; 1096 1097 1098 1051 p_ref r1(args); 1052 switch (number) 1053 { 1054 case 1: 1055 { 1056 return abs(current_object->x-current_level->attacker(current_object)->x); 1057 } break; 1058 case 2: 1059 { 1060 return abs(current_object->y-current_level->attacker(current_object)->y); 1061 } break; 1062 case 3: 1063 { 1064 if( !current_object->controller() ) 1065 { 1066 lbreak("object is not a player, cannot determine keypresses"); 1067 } 1068 else 1069 { 1070 return current_object->controller()->key_down(lnumber_value(CAR(args))); 1071 } 1072 } break; 1073 case 4: 1074 { 1075 return the_game->key_down(lnumber_value(CAR(args))); 1076 } break; 1077 case 5: 1078 { 1079 return current_level->attacker(current_object)->state; 1080 } break; 1081 case 6: 1082 { 1083 return current_object->aitype(); 1084 } break; 1085 case 7: 1086 { 1087 if (!current_object->keep_ai_info()) 1088 current_object->set_aistate(0); 1089 return current_object->aistate(); 1090 } break; 1091 case 8: 1092 { 1093 int ns=lnumber_value(CAR(args)); 1094 current_object->set_aistate_time(0); 1095 current_object->set_aistate(ns); return 1; 1096 } break; 1097 case 9: 1098 { 1099 1099 /* if (rcheck_lp) 1100 1100 { 1101 1102 1103 1104 1105 1106 1101 char str[100]; 1102 sprintf(str,"\n\nTick %d, Rand_on %d\n",current_level->tick_counter(),rand_on); 1103 rcheck_lp->write(str,strlen(str)+1); 1104 current_print_file=rcheck_lp; 1105 print_trace_stack(6); 1106 current_print_file=NULL; 1107 1107 }*/ 1108 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1109 return jrandom(lnumber_value(CAR(args))); 1110 } break; 1111 case 10 : return current_object->aistate_time(); break; 1112 case 11 : return current_object->state; break; 1113 case 12: 1114 { 1115 if (current_level->attacker(current_object)->x>current_object->x) 1116 return 1; 1117 else 1118 return -1; 1119 } break; 1120 case 13: 1121 { 1122 return current_object->move(lnumber_value(CAR(args)),lnumber_value(CAR(CDR(args))), lnumber_value(CAR(CDR(CDR(args))))); 1123 } break; 1124 case 14: 1125 { 1126 if (current_object->direction>0) 1127 return 1; 1128 else 1129 return -1; 1130 } break; 1131 1131 case 15 : return current_object->otype; break; 1132 1132 case 16 : return current_object->next_picture(); break; 1133 1133 case 17 : current_object->set_fade_dir(lnumber_value(CAR(args))); return 1; break; 1134 case 18 : 1135 { 1134 case 18 : 1135 { 1136 1136 int cx=lnumber_value(CAR(args)); 1137 1137 args=CDR(args); … … 1159 1159 case 28 : 1160 1160 { return (dev & EDIT_MODE); } break; 1161 case 29 : 1161 case 29 : 1162 1162 { current_object->draw_above(current_view); return 1; } break; 1163 1163 case 30 : return current_object->x; break; 1164 1164 case 31 : return current_object->y; break; 1165 case 32 : 1165 case 32 : 1166 1166 { int32_t v=lnumber_value(CAR(args)); 1167 1167 current_object->x=v; 1168 1168 // current_object->last_x=v; 1169 return 1; 1170 } break; 1171 case 33 : 1169 return 1; 1170 } break; 1171 case 33 : 1172 1172 { int32_t v=lnumber_value(CAR(args)); 1173 1173 current_object->y=v; 1174 1174 // current_object->last_y=v; 1175 return 1; 1175 return 1; 1176 1176 } break; 1177 1177 1178 1178 case 34 : { return current_level->push_characters(current_object,lnumber_value(CAR(args)), 1179 1180 1181 1182 case 37 : 1179 lnumber_value(CAR(CDR(args)))); 1180 } break; 1181 1182 case 37 : 1183 1183 { 1184 1184 int32_t s=lnumber_value(CAR(args)); 1185 current_object->set_state((character_state)s); 1185 current_object->set_state((character_state)s); 1186 1186 return (s==current_object->state); 1187 1187 } break; … … 1195 1195 case 44 : current_object->set_xvel(lnumber_value(CAR(args))); return 1; break; 1196 1196 case 45 : current_object->set_yvel(lnumber_value(CAR(args))); return 1; break; 1197 case 46 : if (current_level->attacker(current_object)->x>current_object->x) return -1; 1197 case 46 : if (current_level->attacker(current_object)->x>current_object->x) return -1; 1198 1198 else return 1; break; 1199 1199 case 47 : return lnumber_value(CAR(args))&BLOCKED_LEFT; break; … … 1208 1208 case 56 : return current_object->direction; break; 1209 1209 case 57 : current_object->direction=lnumber_value(CAR(args)); break; 1210 case 58 : 1210 case 58 : 1211 1211 { 1212 1212 int x1=lnumber_value(CAR(args)); 1213 if (!current_object->controller()) 1213 if (!current_object->controller()) 1214 1214 { lbreak("set_freeze_time : object is not a focus\n"); } 1215 1215 else current_object->controller()->freeze_time=x1; return 1; 1216 1216 } break; 1217 1217 case 59 : return menu(args,big_font); break; 1218 case 60 : 1218 case 60 : 1219 1219 { event ev; dev_cont->do_command(lstring_value(CAR(args)),ev); return 1; } break; 1220 1220 case 61 : the_game->set_state(lnumber_value(CAR(args))); break; 1221 1221 1222 case 62 : 1222 case 62 : 1223 1223 { 1224 1224 int x1=lnumber_value(CAR(args)); args=CDR(args); … … 1233 1233 case 66 : scene_director.scroll_text(lstring_value(CAR(args))); break; 1234 1234 case 67 : scene_director.set_pan(lnumber_value(CAR(args)), 1235 1236 1235 lnumber_value(CAR(CDR(args))), 1236 lnumber_value(CAR(CDR(CDR(args))))); break; 1237 1237 case 68 : scene_director.wait(CAR(args)); break; 1238 1238 1239 1239 1240 1240 case 73 : the_game->set_level(new level(lnumber_value(CAR(args)), 1241 1242 1243 case 74 : 1244 { if (current_level) delete current_level; 1245 current_level=new level(100,100,"new_level"); 1246 } break; 1247 case 75 : 1241 lnumber_value(CAR(CDR(args))), 1242 lstring_value(CAR(CDR(CDR(args)))))); break; 1243 case 74 : 1244 { if (current_level) delete current_level; 1245 current_level=new level(100,100,"new_level"); 1246 } break; 1247 case 75 : 1248 1248 { 1249 1249 int amount=lnumber_value(CAR(args)); args=CDR(args); … … 1252 1252 if (args) 1253 1253 { 1254 1255 1254 xv=lnumber_value(CAR(args)); args=CDR(args); 1255 yv=lnumber_value(CAR(args)); 1256 1256 } 1257 1257 o->do_damage(amount,current_object,current_object->x,current_object->y,xv,yv); 1258 1258 } break; 1259 1259 case 76 : return current_object->hp(); break; 1260 case 77 : 1260 case 77 : 1261 1261 { 1262 1262 game_object *o=(game_object *)lpointer_value(CAR(args)); 1263 if (!o->controller()) 1264 1263 if (!o->controller()) 1264 printf("set shift : object is not a focus\n"); 1265 1265 else o->controller()->shift_down=lnumber_value(CAR(CDR(args))); return 1; 1266 1266 } break; 1267 case 78 : 1267 case 78 : 1268 1268 { 1269 1269 game_object *o=(game_object *)lpointer_value(CAR(args)); 1270 if (!o->controller()) 1271 1270 if (!o->controller()) 1271 printf("set shift : object is not a focus\n"); 1272 1272 else o->controller()->shift_right=lnumber_value(CAR(CDR(args))); return 1; 1273 1273 } break; … … 1283 1283 case 89 : return morph_detail; break; 1284 1284 case 90 : current_object->morph_into(lnumber_value(CAR(args)),NULL, 1285 1286 1285 lnumber_value(CAR(CDR(args))), 1286 lnumber_value(CAR(CDR(CDR(args))))); return 1; break; 1287 1287 case 91 : current_object->add_object((game_object *)lpointer_value(CAR(args))); return 1; break; 1288 case 92 : 1288 case 92 : 1289 1289 { 1290 1290 int32_t cx1,x1=lnumber_value(CAR(args)); args=lcdr(args); … … 1308 1308 case 103 : return current_object->total_lights(); break; 1309 1309 1310 case 104 : 1310 case 104 : 1311 1311 { light_source *l=(light_source *)lpointer_value(CAR(args)); 1312 1312 int32_t x=lnumber_value(CAR(CDR(args))); … … 1316 1316 return 1; 1317 1317 } break; 1318 case 105 : 1318 case 105 : 1319 1319 { light_source *l=(light_source *)lpointer_value(CAR(args)); 1320 1320 int32_t x=lnumber_value(CAR(CDR(args))); … … 1324 1324 return 1; 1325 1325 } break; 1326 case 106 : 1326 case 106 : 1327 1327 { light_source *l=(light_source *)lpointer_value(CAR(args)); 1328 1328 l->x=lnumber_value(CAR(CDR(args))); … … 1330 1330 return 1; 1331 1331 } break; 1332 case 107 : 1332 case 107 : 1333 1333 { light_source *l=(light_source *)lpointer_value(CAR(args)); 1334 1334 l->y=lnumber_value(CAR(CDR(args))); … … 1336 1336 return 1; 1337 1337 } break; 1338 case 108 : 1338 case 108 : 1339 1339 { light_source *l=(light_source *)lpointer_value(CAR(args)); 1340 1340 l->xshift=lnumber_value(CAR(CDR(args))); … … 1342 1342 return 1; 1343 1343 } break; 1344 case 109 : 1344 case 109 : 1345 1345 { light_source *l=(light_source *)lpointer_value(CAR(args)); 1346 1346 l->yshift=lnumber_value(CAR(CDR(args))); … … 1367 1367 case 127 : { dprintf("trap\n"); } break; // I use this to set gdb break points 1368 1368 case 128 : { return current_level->platform_push(current_object,lnumber_value(CAR(args)), 1369 1370 1369 lnumber_value(CAR(CDR(args)))); 1370 } break; 1371 1371 case 133 : // def_sound 1372 1372 { … … 1374 1374 if (CDR(args)) 1375 1375 { 1376 1377 1378 1379 1380 1381 1382 1376 sym=(lisp_symbol *)lcar(args); 1377 if (item_type(sym)!=L_SYMBOL) 1378 { 1379 lbreak("expecting first arg to def-character to be a symbol!\n"); 1380 exit(0); 1381 } 1382 args=CDR(args); 1383 1383 } 1384 1384 … … 1387 1387 int id=cache.reg(lstring_value(lcar(args)),NULL,SPEC_EXTERN_SFX,1); 1388 1388 if (sym) 1389 set_symbol_number(sym,id); // set the symbol value to sfx id 1389 set_symbol_number(sym,id); // set the symbol value to sfx id 1390 1390 current_space=sp; 1391 1391 return id; … … 1402 1402 else 1403 1403 { 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 } else cache.sfx(id)->play(vol); 1404 int vol=lnumber_value(lcar(a)); a=CDR(a); 1405 if (a) 1406 { 1407 int32_t x=lnumber_value(lcar(a)); a=CDR(a); 1408 if (!a) 1409 { 1410 lprint(args); 1411 lbreak("expecting y after x in play_sound\n"); 1412 exit(1); 1413 } 1414 int32_t y=lnumber_value(lcar(a)); 1415 the_game->play_sound(id,vol,x,y); 1416 } else cache.sfx(id)->play(vol); 1417 1417 } 1418 1418 … … 1431 1431 int32_t x=lnumber_value(CAR(args)); args=CDR(args); 1432 1432 if (x<0 || x>=total_weapons) 1433 { 1434 1435 1433 { 1434 lbreak("weapon out of range (%d)\n",x); 1435 exit(0); 1436 1436 } 1437 1437 return weapon_types[x]; … … 1454 1454 else 1455 1455 { 1456 1457 1458 1459 1460 1461 } 1456 int32_t x=lnumber_value(CAR(args)); args=CDR(args); 1457 int32_t y=lnumber_value(CAR(args)); args=CDR(args); 1458 if (x<0 || x>=total_weapons) 1459 { lbreak("weapon out of range (%d)\n",x); exit(0); } 1460 v->add_ammo(x,y); 1461 } 1462 1462 } break; 1463 1463 case 145 : … … 1476 1476 view *v=current_object->controller(); 1477 1477 if (!v) { lbreak("current_weapon_type : object cannot hold weapons\n"); 1478 return 0; } 1478 return 0; } 1479 1479 else return v->current_weapon; 1480 1480 } break; … … 1489 1489 if (v) v->give_weapon(x); 1490 1490 } break; 1491 case 151 : 1491 case 151 : 1492 1492 { 1493 1493 int a=lnumber_value(CAR(args)); 1494 1494 if (a<0 || a>=TOTAL_ABILITIES) 1495 1495 { 1496 1497 1498 1499 1496 lprint(args); 1497 lbreak("bad ability number for get_ability, should be 0..%d, not %d\n", 1498 TOTAL_ABILITIES,a); 1499 exit(0); 1500 1500 } 1501 1501 return get_ability(current_object->otype,(ability)a); … … 1506 1506 if (!v) dprintf("Can't use reset_player on non-players\n"); 1507 1507 else 1508 v->reset_player(); 1508 v->reset_player(); 1509 1509 } break; 1510 1510 case 153 : … … 1524 1524 int32_t yvel=-(lisp_sin(ang)>>8)*(mag>>8); 1525 1525 current_object->set_yvel(yvel>>16); 1526 current_object->set_fyvel((yvel&0xffff)>>8); 1526 current_object->set_fyvel((yvel&0xffff)>>8); 1527 1527 } break; 1528 1528 case 155 : … … 1530 1530 int tframes=current_object->total_frames(),f; 1531 1531 1532 int32_t ang1=lnumber_value(CAR(args)); args=CDR(args); 1533 if (ang1<0) ang1=(ang1%360)+360; 1532 int32_t ang1=lnumber_value(CAR(args)); args=CDR(args); 1533 if (ang1<0) ang1=(ang1%360)+360; 1534 1534 else if (ang1>=360) ang1=ang1%360; 1535 int32_t ang2=lnumber_value(CAR(args)); args=CDR(args); 1536 if (ang2<0) ang2=(ang2%360)+360; 1535 int32_t ang2=lnumber_value(CAR(args)); args=CDR(args); 1536 if (ang2<0) ang2=(ang2%360)+360; 1537 1537 else if (ang2>=360) ang2=ang2%360; 1538 1538 … … 1540 1540 if (ang1>ang2) 1541 1541 { 1542 if (ang<ang1 && ang>ang2) 1543 1544 else if (ang>=ang1) 1545 1546 else 1547 1542 if (ang<ang1 && ang>ang2) 1543 return 0; 1544 else if (ang>=ang1) 1545 f=(ang-ang1)*tframes/(359-ang1+ang2+1); 1546 else 1547 f=(359-ang1+ang)*tframes/(359-ang1+ang2+1); 1548 1548 } else if (ang<ang1 || ang>ang2) 1549 1549 return 0; … … 1567 1567 int32_t am=lnumber_value(CAR(args)); args=CDR(args); 1568 1568 game_object *from=(game_object *)lpointer_value(CAR(args)); args=CDR(args); 1569 int32_t hitx=lnumber_value(CAR(args)); args=CDR(args); 1570 int32_t hity=lnumber_value(CAR(args)); args=CDR(args); 1571 int32_t px=lnumber_value(CAR(args)); args=CDR(args); 1569 int32_t hitx=lnumber_value(CAR(args)); args=CDR(args); 1570 int32_t hity=lnumber_value(CAR(args)); args=CDR(args); 1571 int32_t px=lnumber_value(CAR(args)); args=CDR(args); 1572 1572 int32_t py=lnumber_value(CAR(args)); args=CDR(args); 1573 1573 current_object->damage_fun(am,from,hitx,hity,px,py); … … 1579 1579 if (!v) dprintf("make_view_solid : object has no view\n"); 1580 1580 else 1581 v->draw_solid=lnumber_value(CAR(args)); 1581 v->draw_solid=lnumber_value(CAR(args)); 1582 1582 } break; 1583 1583 case 172 : … … 1589 1589 if (r<0 || b<0 || g<0 || r>255 || g>255 || b>255) 1590 1590 { 1591 1592 1593 1591 lprint(args); 1592 lbreak("color out of range (0..255) in color lookup\n"); 1593 exit(0); 1594 1594 } 1595 1595 return color_table->lookup_color(r>>3,g>>3,b>>3); … … 1630 1630 bg_xdiv=lnumber_value(CAR(args)); args=CDR(args); 1631 1631 bg_ymul=lnumber_value(CAR(args)); args=CDR(args); 1632 bg_ydiv=lnumber_value(CAR(args)); 1632 bg_ydiv=lnumber_value(CAR(args)); 1633 1633 if (bg_xdiv==0) { bg_xdiv=1; lprint(args); dprintf("bg_set_scroll : cannot set xdiv to 0\n"); } 1634 1634 if (bg_ydiv==0) { bg_ydiv=1; lprint(args); dprintf("bg_set_scroll : cannot set ydiv to 0\n"); } 1635 1635 } break; 1636 case 179 : 1636 case 179 : 1637 1637 { 1638 1638 view *v=lget_view(CAR(args),"set_ambient_light"); args=CDR(args); … … 1641 1641 } break; 1642 1642 case 180 : return lget_view(CAR(args),"ambient_light")->ambient; break; 1643 case 181 : 1643 case 181 : 1644 1644 { 1645 1645 int x=current_object->total_objects(); … … 1658 1658 case 189 : return current_object->fxacel(); break; 1659 1659 case 190 : return current_object->fyacel(); break; 1660 case 191 : 1661 { 1662 // char *fn=lstring_value(CAR(args)); args=CDR(args); 1660 case 191 : 1661 { 1662 // char *fn=lstring_value(CAR(args)); args=CDR(args); 1663 1663 // stat_bar=cache.reg_object(fn,CAR(args),SPEC_IMAGE,1); 1664 1664 } break; 1665 case 192 : 1666 { 1665 case 192 : 1666 { 1667 1667 int32_t x=lnumber_value(CAR(args)); args=CDR(args); 1668 1668 int32_t y=lnumber_value(CAR(args)); args=CDR(args); … … 1670 1670 if (x<0 || y<0 || x>=current_level->foreground_width() || y>=current_level->foreground_width()) 1671 1671 lbreak("%d %d is out of range of fg map",x,y); 1672 else 1672 else 1673 1673 current_level->put_fg(x,y,type); 1674 1674 } break; 1675 1675 case 193 : 1676 { 1676 { 1677 1677 int32_t x=lnumber_value(CAR(args)); args=CDR(args); 1678 1678 int32_t y=lnumber_value(CAR(args)); … … 1681 1681 else return current_level->get_fg(x,y); 1682 1682 } break; 1683 case 194 : 1684 { 1683 case 194 : 1684 { 1685 1685 int32_t x=lnumber_value(CAR(args)); args=CDR(args); 1686 1686 int32_t y=lnumber_value(CAR(args)); args=CDR(args); … … 1688 1688 if (x<0 || y<0 || x>=current_level->background_width() || y>=current_level->background_width()) 1689 1689 lbreak("%d %d is out of range of fg map",x,y); 1690 else 1690 else 1691 1691 current_level->put_bg(x,y,type); 1692 1692 } break; 1693 1693 case 195 : 1694 { 1694 { 1695 1695 int32_t x=lnumber_value(CAR(args)); args=CDR(args); 1696 1696 int32_t y=lnumber_value(CAR(args)); … … 1705 1705 if (fp->open_failure()) 1706 1706 { 1707 1707 delete fp; 1708 1708 lbreak("load_palette : could not open file %s for reading",lstring_value(CAR(args))); 1709 1709 exit(1); 1710 1710 } else 1711 1711 { 1712 1713 1714 1715 1716 1717 1718 1719 1720 1712 spec_directory sd(fp); 1713 spec_entry *se=sd.find(SPEC_PALETTE); 1714 if (!se) lbreak("File %s has no palette!\n",lstring_value(CAR(args))); 1715 else 1716 { 1717 if (pal) delete pal; 1718 pal=new palette(se,fp); 1719 } 1720 delete fp; 1721 1721 } 1722 1722 } break; … … 1726 1726 if (fp->open_failure()) 1727 1727 { 1728 1728 delete fp; 1729 1729 lbreak("load_color_filter : could not open file %s for reading",lstring_value(CAR(args))); 1730 1730 exit(1); 1731 1731 } else 1732 1732 { 1733 1734 1735 1736 1737 1738 1739 1740 1741 1733 spec_directory sd(fp); 1734 spec_entry *se=sd.find(SPEC_COLOR_TABLE); 1735 if (!se) lbreak("File %s has no color filter!",lstring_value(CAR(args))); 1736 else 1737 { 1738 if (color_table) delete color_table; 1739 color_table=new color_filter(se,fp); 1740 } 1741 delete fp; 1742 1742 } 1743 1743 } break; … … 1754 1754 if (args) 1755 1755 if (!CAR(args)) top=0; 1756 1756 1757 1757 int32_t oxv=xv,oyv=yv; 1758 1758 current_object->try_move(current_object->x,current_object->y,xv,yv,1|top); … … 1767 1767 } break; 1768 1768 case 202 : 1769 { 1769 { 1770 1770 int32_t x1=lnumber_value(CAR(args)); args=CDR(args); 1771 1771 int32_t y1=lnumber_value(CAR(args)); args=CDR(args); … … 1776 1776 current_level->foreground_intersect(x1,y1,x2,y2); 1777 1777 if (x2!=nx2 || y2!=ny2) return 0; 1778 1778 1779 1779 if (block_all) 1780 1780 current_level->all_boundary_setback(current_object,x1,y1,x2,y2); … … 1788 1788 char *fn=lstring_value(CAR(args)); args=CDR(args); 1789 1789 char *name=lstring_value(CAR(args)); 1790 big_font_pict=cache.reg(fn,name,SPEC_IMAGE,1); 1790 big_font_pict=cache.reg(fn,name,SPEC_IMAGE,1); 1791 1791 } break; 1792 1792 case 204 : … … 1794 1794 char *fn=lstring_value(CAR(args)); args=CDR(args); 1795 1795 char *name=lstring_value(CAR(args)); 1796 small_font_pict=cache.reg(fn,name,SPEC_IMAGE,1); 1796 small_font_pict=cache.reg(fn,name,SPEC_IMAGE,1); 1797 1797 } break; 1798 1798 case 205 : … … 1800 1800 char *fn=lstring_value(CAR(args)); args=CDR(args); 1801 1801 char *name=lstring_value(CAR(args)); 1802 console_font_pict=cache.reg(fn,name,SPEC_IMAGE,1); 1802 console_font_pict=cache.reg(fn,name,SPEC_IMAGE,1); 1803 1803 } break; 1804 1804 case 206 : … … 1807 1807 if (x<current_object->total_frames()) 1808 1808 current_object->current_frame=x; 1809 else 1810 1811 } break; 1812 1809 else 1810 lbreak("%d out of range for set_current_frame",x); 1811 } break; 1812 1813 1813 case 208 : 1814 1814 { … … 1890 1890 case 224 : 1891 1891 { 1892 current_object->set_hp(lnumber_value(CAR(args))); 1892 current_object->set_hp(lnumber_value(CAR(args))); 1893 1893 } break; 1894 1894 case 225 : … … 1924 1924 for (int i=0;i<256;i++) 1925 1925 { 1926 1927 1928 1926 r=(int)*addr+ra; if (r>255) r=255; else if (r<0) r=0; *addr=(uint8_t)r; addr++; 1927 g=(int)*addr+ga; if (g>255) g=255; else if (g<0) g=0; *addr=(uint8_t)g; addr++; 1928 b=(int)*addr+ba; if (b>255) b=255; else if (b<0) b=0; *addr=(uint8_t)b; addr++; 1929 1929 } 1930 1930 p->load(); … … 1941 1941 view *v=current_object->controller(); 1942 1942 if (!v) lbreak("object has no view : local_player"); 1943 else 1944 { 1945 1946 1947 1948 v->current_weapon=x; 1943 else 1944 { 1945 int32_t x=lnumber_value(CAR(args)); 1946 if (x<0 || x>=total_weapons) 1947 { lbreak("weapon out of range (%d)\n",x); exit(0); } 1948 v->current_weapon=x; 1949 1949 } 1950 1950 } break; … … 1960 1960 } break; 1961 1961 1962 case 233 : 1962 case 233 : 1963 1963 { int x=0; view *v=player_list; for (;v;v=v->next,x++); return x; } break; 1964 1964 … … 1978 1978 } break; 1979 1979 case 235 : 1980 { if (current_level) return current_level->tick_counter(); 1980 { if (current_level) return current_level->tick_counter(); 1981 1981 else return 0; } break; 1982 1982 case 236 : … … 1997 1997 { current_level->to_back(current_object); } break; 1998 1998 case 241 : 1999 { 1999 { 2000 2000 view *v=current_object->controller(); 2001 2001 if (!v) { lprint(args); printf("get_player_inputs : object has no view!\n"); } … … 2003 2003 } break; 2004 2004 case 242 : 2005 { 2005 { 2006 2006 view *v=current_object->controller(); 2007 2007 if (!v) { lprint(args); printf("get_player_inputs : object has no view!\n"); } … … 2044 2044 int32_t cx2=lnumber_value(CAR(args)); args=lcdr(args); 2045 2045 int32_t cy2=lnumber_value(CAR(args)); args=lcdr(args); 2046 int32_t c1=lnumber_value(CAR(args)); args=lcdr(args); 2046 int32_t c1=lnumber_value(CAR(args)); args=lcdr(args); 2047 2047 screen->bar(cx1,cy1,cx2,cy2,c1); 2048 2048 } break; … … 2055 2055 if ((sound_avail&MUSIC_INITIALIZED)) 2056 2056 { 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2057 char *fn=lstring_value(CAR(args)); 2058 if (current_song) 2059 { 2060 if (current_song->playing()) 2061 current_song->stop(); 2062 delete current_song; 2063 } 2064 current_song=new song(fn); 2065 current_song->play(music_volume); 2066 dprintf("Playing %s at volume %d\n",fn,music_volume); 2067 2067 } 2068 2068 } break; … … 2105 2105 view *v=current_object->controller(); 2106 2106 if (!v) { lprint(args); printf("get_player_inputs : object has no view!\n"); } 2107 else v->kills=lnumber_value(CAR(args)); 2107 else v->kills=lnumber_value(CAR(args)); 2108 2108 } break; 2109 2109 case 259 : … … 2111 2111 view *v=current_object->controller(); 2112 2112 if (!v) { lprint(args); printf("get_player_inputs : object has no view!\n"); } 2113 else v->tkills=lnumber_value(CAR(args)); 2113 else v->tkills=lnumber_value(CAR(args)); 2114 2114 } break; 2115 2115 case 260 : … … 2117 2117 view *v=current_object->controller(); 2118 2118 if (!v) { lprint(args); printf("get_player_inputs : object has no view!\n"); } 2119 else v->secrets=lnumber_value(CAR(args)); 2119 else v->secrets=lnumber_value(CAR(args)); 2120 2120 } break; 2121 2121 case 261 : … … 2123 2123 view *v=current_object->controller(); 2124 2124 if (!v) { lprint(args); printf("get_player_inputs : object has no view!\n"); } 2125 else v->tsecrets=lnumber_value(CAR(args)); 2125 else v->tsecrets=lnumber_value(CAR(args)); 2126 2126 } break; 2127 2127 case 262 : … … 2188 2188 } break; 2189 2189 case 276 : 2190 { 2190 { 2191 2191 if (!main_net_cfg) return 0; 2192 2192 return become_server(game_name); … … 2210 2210 view *v=current_object->controller(); 2211 2211 if (!v) { lbreak("get_player_name : object has no view!\n"); } 2212 else strcpy(v->name,lstring_value(CAR(args))); 2212 else strcpy(v->name,lstring_value(CAR(args))); 2213 2213 } break; 2214 2214 case 282 : … … 2248 2248 if (change_dir(lstring_value(CAR(args)))) 2249 2249 return 1; 2250 else return 0; 2250 else return 0; 2251 2251 } break; 2252 2252 case 287 : … … 2254 2254 void *title=CAR(args); args=CDR(args); 2255 2255 void *source=CAR(args); args=CDR(args); 2256 void *dest=CAR(args); args=CDR(args); 2257 2258 return nice_copy(lstring_value(title),lstring_value(source),lstring_value(dest)); 2256 void *dest=CAR(args); args=CDR(args); 2257 2258 return nice_copy(lstring_value(title),lstring_value(source),lstring_value(dest)); 2259 2259 } break; 2260 2260 case 288 : … … 2264 2264 case 289 : 2265 2265 { 2266 set_login(lstring_value(CAR(args))); 2266 set_login(lstring_value(CAR(args))); 2267 2267 } break; 2268 2268 case 290 : … … 2283 2283 if (main_net_cfg && (main_net_cfg->state==net_configuration::CLIENT || main_net_cfg->state==net_configuration::SERVER)) 2284 2284 { 2285 2286 2287 2288 2289 2285 view *v=player_list; 2286 for (;v;v=v->next) 2287 if (v->kills>=main_net_cfg->kills) 2288 return 1; 2289 2290 2290 2291 2291 } else return 0; … … 2296 2296 for (;v;v=v->next) 2297 2297 { 2298 2298 v->tkills+=v->kills; 2299 2299 2300 2300 v->kills=0; 2301 2302 2303 2304 2305 2306 2307 current_object=o; 2301 game_object *o=current_object; 2302 current_object=v->focus; 2303 2304 eval_function((lisp_symbol *)l_restart_player,NULL); 2305 v->reset_player(); 2306 v->focus->set_aistate(0); 2307 current_object=o; 2308 2308 } 2309 2309 … … 2337 2337 { 2338 2338 case L_FIXED_POINT : 2339 case L_NUMBER : 2340 { return lnumber_value(v); } break; 2341 default : return def; 2339 case L_NUMBER : 2340 { return lnumber_value(v); } break; 2341 default : return def; 2342 2342 } 2343 2343 } else return def; -
abuse/trunk/src/clisp.hpp
r58 r124 16 16 extern void *l_statbar_ammo_x,*l_statbar_ammo_y, 17 17 *l_statbar_ammo_w,*l_statbar_ammo_h, 18 18 *l_statbar_ammo_bg_color, 19 19 20 20 *l_statbar_health_x,*l_statbar_health_y, 21 21 *l_statbar_health_w,*l_statbar_health_h, 22 22 *l_statbar_health_bg_color, 23 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 24 *l_statbar_logo_x,*l_statbar_logo_y, 25 *l_object,*l_tile,*l_fire_object, 26 *l_player_draw,*l_sneaky_draw, 27 *l_draw_fast,*l_player_tints,*l_next_song, 28 *l_level_load_start, 29 *l_level_load_end, 30 *l_cdc_logo, 31 *l_keep_backup, 32 *l_switch_to_powerful, 33 *l_mouse_can_switch, 34 *l_ask_save_slot, 35 *l_get_local_input, 36 *l_post_render, 37 *l_chat_input, 38 *l_player_text_color, 39 *l_level_loaded; // called when a new level is loaded 40 40 41 41 -
abuse/trunk/src/collide.cpp
r56 r124 17 17 public : 18 18 int32_t total,x1,y1,x2,y2; 19 game_object **touch; 19 game_object **touch; 20 20 collide_patch *next; 21 21 collide_patch(int32_t X1, int32_t Y1, int32_t X2, int32_t Y2, collide_patch *Next) 22 { 22 { 23 23 x1=X1; y1=Y1; x2=X2; y2=Y2; 24 24 next=Next; … … 33 33 34 34 collide_patch *collide_patch::copy(collide_patch *Next) 35 { 36 collide_patch *p=new collide_patch(x1,y1,x2,y2,Next); 35 { 36 collide_patch *p=new collide_patch(x1,y1,x2,y2,Next); 37 37 p->total=total; 38 if (total) 38 if (total) 39 39 { 40 40 p->touch=(game_object **)jmalloc(total*sizeof(game_object *),"collide patches"); 41 41 memcpy(p->touch,touch,total*(sizeof(game_object *))); 42 42 } 43 else 44 p->touch=NULL; 43 else 44 p->touch=NULL; 45 45 return p; 46 46 } 47 47 48 48 49 void add_collide(collide_patch *&first, int32_t x1, int32_t y1, int32_t x2, int32_t y2, 50 49 void add_collide(collide_patch *&first, int32_t x1, int32_t y1, int32_t x2, int32_t y2, 50 game_object *who) 51 51 { 52 52 collide_patch *next; … … 59 59 if (x1>p->x1) 60 60 { 61 62 61 first=p->copy(first); 62 first->x2=x1-1; 63 63 } 64 64 if (x2<p->x2) 65 65 { 66 67 66 first=p->copy(first); 67 first->x1=x2+1; 68 68 } 69 69 if (y1>p->y1) 70 70 { 71 72 73 74 71 first=p->copy(first); 72 first->x1=x1; 73 first->x2=x2; 74 first->y2=y1-1; 75 75 } 76 76 if (y2<p->y2) 77 77 { 78 79 80 81 78 first=p->copy(first); 79 first->x1=x1; 80 first->x2=x2; 81 first->y1=y2+1; 82 82 } 83 83 p->x1=x1; p->y1=y1; p->x2=x2; p->y2=y2; 84 84 85 p->total++; 85 p->total++; 86 86 p->touch=(game_object **)jrealloc(p->touch,sizeof(game_object *)*p->total,"object_patch_list"); 87 87 p->touch[p->total-1]=who; … … 100 100 if (y2>p->y2) 101 101 add_collide(first,p->x1,p->y2+1,p->x2,y2,who); 102 p->total++; 102 p->total++; 103 103 p->touch=(game_object **)jrealloc(p->touch,sizeof(game_object *)*p->total,"object_patch_list"); 104 104 p->touch[p->total-1]=who; … … 107 107 108 108 // see if we intersect another rect 109 if (!(x2<p->x1 || y2<p->y1 || x1>p->x2 || y1>p->y2)) 109 if (!(x2<p->x1 || y2<p->y1 || x1>p->x2 || y1>p->y2)) 110 110 { 111 111 int ax1,ay1,ax2,ay2; … … 113 113 { 114 114 add_collide(first,x1,max(y1,p->y1),p->x1-1,min(y2,p->y2),who); 115 115 ax1=p->x1; 116 116 } else 117 117 ax1=x1; 118 118 119 119 if (x2>p->x2) 120 120 { 121 121 add_collide(first,p->x2+1,max(y1,p->y1),x2,min(y2,p->y2),who); 122 123 } 122 ax2=p->x2; 123 } 124 124 else 125 125 ax2=x2; 126 126 127 127 if (y1<p->y1) 128 { 128 { 129 129 add_collide(first,x1,y1,x2,p->y1-1,who); 130 131 } else 132 130 ay1=p->y1; 131 } else 132 ay1=y1; 133 133 134 134 if (y2>p->y2) 135 135 { 136 136 add_collide(first,x1,p->y2+1,x2,y2,who); 137 138 } else 139 140 141 142 add_collide(first,ax1,ay1,ax2,ay2,who); 143 144 return ; 145 } 146 147 } 148 137 ay2=p->y2; 138 } else 139 ay2=y2; 140 141 142 add_collide(first,ax1,ay1,ax2,ay2,who); 143 144 return ; 145 } 146 147 } 148 149 149 first=new collide_patch(x1,y1,x2,y2,first); 150 150 first->total=1; … … 166 166 subject->picture_space(sx1,sy1,sx2,sy2); 167 167 rec=NULL; 168 168 169 169 170 170 for (int j=0;j<target_total && !rec;j++) 171 171 { 172 target=target_list[j]; 172 target=target_list[j]; 173 173 target->picture_space(tx1,ty1,tx2,ty2); 174 174 if (!(sx2<tx1 || sy2<ty1 || sx1>tx2 || sy1>ty2)) // check to see if picture spaces collide 175 175 { 176 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 xp1=target->x+target->tx(*t_dat); t_dat++;201 202 xp2=target->x+target->tx(*t_dat); 203 yp2=target->y+target->ty(t_dat[1]); 204 205 x1=subject->x+subject->tx(s_dat[0]); 206 y1=subject->y+subject->ty(s_dat[1]); 207 x2=subject->x+subject->tx(s_dat[2]); 208 y2=subject->y+subject->ty(s_dat[3]); 209 210 211 212 213 int32_t _x2=x2,_y2=y2;214 215 216 217 218 219 220 221 222 223 224 225 } 226 177 try_pushback(subject,target); 178 179 if (subject->can_hurt(target)) // see if we can hurt him before calculating 180 { 181 t_centerx=target->x_center(); 182 point_list *s_hit,*t_damage; 183 184 s_hit=subject->current_figure()->hit; 185 186 if (target->direction>0) 187 t_damage=target->current_figure()->f_damage; 188 else 189 t_damage=target->current_figure()->b_damage; 190 191 unsigned char *s_dat=s_hit->data,*t_dat; 192 int i,j; 193 for (i=(int)s_hit->tot-1;i>0 && !rec;i--) 194 { 195 for (t_dat=t_damage->data,j=(int)t_damage->tot-1;j>0 && !rec;j--) 196 { 197 int32_t x1,y1,x2,y2, // define the two line segments to check 198 xp1,yp1,xp2,yp2; 199 200 xp1=target->x+target->tx(*t_dat); t_dat++; 201 yp1=target->y+target->ty(*t_dat); t_dat++; 202 xp2=target->x+target->tx(*t_dat); 203 yp2=target->y+target->ty(t_dat[1]); 204 205 x1=subject->x+subject->tx(s_dat[0]); 206 y1=subject->y+subject->ty(s_dat[1]); 207 x2=subject->x+subject->tx(s_dat[2]); 208 y2=subject->y+subject->ty(s_dat[3]); 209 210 211 // ok, now we know which line segemnts to check for intersection 212 // now check to see if (x1,y1-x2,y2) intercest with (xp1,yp1-xp2,yp2) 213 int32_t _x2=x2,_y2=y2; 214 setback_intersect(x1, y1, x2, y2, xp1, yp1, xp2, yp2,0); 215 216 217 if (x2!=_x2 || _y2!=y2) 218 { 219 rec=target; 220 hitx=((x1+x2)/2+(xp1+xp2)/2)/2; 221 hity=((y1+y1)/2+(yp1+yp2)/2)/2; 222 } 223 } 224 s_dat+=2; 225 } 226 } 227 227 } 228 228 } … … 231 231 rec->do_damage((int)subject->current_figure()->hit_damage,subject,hitx,hity,0,0); 232 232 subject->note_attack(rec); 233 } 233 } 234 234 } 235 235 } -
abuse/trunk/src/compiled.cpp
r56 r124 149 149 void compiled_uninit() 150 150 { 151 if (bad_guy_array) 151 if (bad_guy_array) 152 152 jfree(bad_guy_array); 153 153 } -
abuse/trunk/src/compiled.hpp
r57 r124 14 14 S_turn_around,S_fire_wait,S_ceil_fire,S_top_walk, 15 15 S_blown_back_dead,S_jump_up,S_hiding,S_weapon_fire, 16 17 18 19 20 16 S_hanging,S_blocking,S_rotate,S_climbing,S_climb_off, 17 S_fly_stopped,S_fast_stopped,S_fast_running,S_fly_running, 18 S_fly_start_run_jump,S_fly_run_jump,S_fly_run_jump_fall,S_fly_end_run_jump, 19 S_fast_start_run_jump,S_fast_run_jump,S_fast_run_jump_fall,S_fast_end_run_jump, 20 S_bright_tint,S_climb_on, 21 21 22 23 24 25 26 27 28 29 22 S_ALAND_SND,S_ASCREAM_SND,S_ASLASH_SND, 23 S_ROCKET_TOP,S_BFG_TOP,S_GRENADE_TOP,S_DFRIS_TOP,S_FIREBOMB_TOP,S_ANT_ROOF, 24 S_MGUN_TOP,S_CLOUD,S_HIDDEN_ANT, 25 S_health_image,S_fly_image,S_fast_image, 26 S_sneaky_image,S_EXPLODE5,S_EXPLODE3,S_ROCKET, 27 S_TRACK_GUN,S_SPRAY_GUN,S_LPING_SND,S_FLY_SND,S_SPEED_SND,S_SCARE_SND, 28 S_LOW_HEALTH_SND,S_BUTTON_PRESS_SND, 29 S_LINK_SND,S_DELETE_SND; 30 30 31 31 32 32 33 33 void compiled_init(); -
abuse/trunk/src/config.cpp
r106 r124 27 27 struct player_keys 28 28 { 29 29 int joy, left, right, up, down, b1, b2, b3, b4; 30 30 }; 31 31 … … 34 34 static int binding_for_player( int player ) 35 35 { 36 37 38 39 40 41 42 43 44 45 46 47 36 char tmp[40]; 37 sprintf( tmp, "player%d", player ); 38 Cell *f = find_symbol( tmp ); 39 if( !NILP( f ) && DEFINEDP( symbol_value( f ) ) ) 40 { 41 void *what = symbol_value( f ); 42 if( what == make_find_symbol( "keyboard" ) ) 43 return 1; 44 else if( what == make_find_symbol( "joystick" ) ) 45 return 2; 46 } 47 return 0; 48 48 } 49 49 … … 51 51 int get_key_binding(char const *dir, int i) 52 52 { 53 54 55 56 57 58 59 60 61 53 char tmp[100], kn[50]; 54 sprintf( tmp, "player%d-%s", i, dir ); 55 Cell *f = find_symbol( tmp ); 56 if( NILP(f) || !DEFINEDP( symbol_value( f ) ) ) 57 return 0; 58 void *k = symbol_value( f ); 59 60 if( item_type( k ) != L_SYMBOL ) 61 return 0; 62 62 63 63 #ifdef SCADALISP 64 64 strcpy( tmp, symbol_name( k ) ); 65 65 #else 66 66 strcpy( tmp, lstring_value( symbol_name( k ) ) ); 67 67 #endif 68 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 69 for( char *c = tmp; *c; c++ ) 70 { 71 *c = tolower( *c ); 72 if( *c == '_' ) 73 *c = ' '; 74 } 75 76 for( int j = 0; j < JK_MAX_KEY; j++ ) 77 { 78 key_name( j, kn ); 79 for( char *c = kn; *c; c++ ) 80 { 81 *c = tolower(*c); 82 } 83 if( !strcmp( kn, tmp ) ) 84 return j; 85 } 86 return 0; 87 87 } 88 88 */ … … 91 91 void get_key_bindings() 92 92 { 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 93 if( key_map ) 94 { 95 jfree( key_map ); 96 } 97 key_map = NULL; 98 99 for( key_players = 0; binding_for_player( key_players + 1); key_players++ ); 100 if( key_players ) 101 { 102 key_map = ( player_keys *)jmalloc(sizeof(player_keys)*key_players,"key bindings"); 103 for( int i = 0; i < key_players; i++ ) 104 { 105 key_map[i].joy = ( binding_for_player( i + 1 ) == 2 ); 106 if( !key_map[i].joy ) 107 { 108 key_map[i].left = get_key_binding( "left", i + 1 ); 109 key_map[i].right = get_key_binding( "right", i + 1 ); 110 key_map[i].up = get_key_binding( "up", i + 1 ); 111 key_map[i].down = get_key_binding( "down", i + 1 ); 112 key_map[i].b4 = get_key_binding( "b4", i + 1 ); 113 key_map[i].b3 = get_key_binding( "b3", i + 1 ); 114 key_map[i].b2 = get_key_binding( "b2", i + 1 ); 115 key_map[i].b1 = get_key_binding( "b1", i + 1 ); 116 } 117 } 118 } 119 else 120 { 121 key_map = NULL; 122 } 123 123 }*/ 124 124 … … 126 126 void get_key_bindings() 127 127 { 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 128 if( key_map ) 129 { 130 jfree( key_map ); 131 } 132 key_map = NULL; 133 134 key_players = 1; 135 key_map = (player_keys *)jmalloc( sizeof( player_keys ) * key_players, "key bindings" ); 136 for( int i = 0; i < key_players; i++ ) 137 { 138 key_map[i].joy = 0; 139 key_map[i].left = get_key_binding( "left", i + 1 ); 140 key_map[i].right = get_key_binding( "right", i + 1 ); 141 key_map[i].up = get_key_binding( "up", i + 1 ); 142 key_map[i].down = get_key_binding( "down", i + 1 ); 143 key_map[i].b4 = get_key_binding( "b4", i + 1 ); 144 key_map[i].b3 = get_key_binding( "b3", i + 1 ); 145 key_map[i].b2 = get_key_binding( "b2", i + 1 ); 146 key_map[i].b1 = get_key_binding( "b1", i + 1 ); 147 } 148 148 } 149 149 … … 153 153 void get_movement(int player, int &x, int &y, int &b1, int &b2, int &b3, int &b4) 154 154 { 155 156 157 /* 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 155 if( player < key_players ) 156 { 157 /* if( key_map[player].joy ) 158 { 159 joy_status( b1,b2,b3,x,y ); 160 b3 = ( b1 && b2 ); 161 b4 = 0; 162 } 163 else if( !wm ) 164 { 165 x = y = b1 = b2 = b3 = b4 = 0; 166 } 167 else*/ 168 { 169 if( is_pressed( key_map[player].left ) ) 170 x = -1; 171 else if( is_pressed( key_map[player].right ) ) 172 x=1; 173 else 174 x = 0; 175 176 if( is_pressed( key_map[player].up ) ) 177 y = -1; 178 else if( is_pressed( key_map[player].down ) ) 179 y = 1; 180 else y = 0; 181 182 if( is_pressed( key_map[player].b1 ) ) 183 b1 = 1; 184 else 185 b1 = 0; 186 187 if( is_pressed( key_map[player].b2 ) ) 188 b2 = 1; 189 else 190 b2 = 0; 191 192 if( is_pressed( key_map[player].b3 ) ) 193 b3 = 1; 194 else 195 b3 = 0; 196 197 if( is_pressed( key_map[player].b4 ) ) 198 b4 = 1; 199 else 200 b4 = 0; 201 } 202 } 203 else 204 { 205 x = y = b1 = b2 = b3 = 0; 206 } 207 207 } 208 208 209 209 void key_bindings(int player, int &left, int &right, int &up, int &down, int &b1, int &b2, int &b3, int &b4) 210 210 { 211 212 213 214 215 216 217 218 211 left = key_map[player].left; 212 right = key_map[player].right; 213 up = key_map[player].up; 214 down = key_map[player].down; 215 b1 = key_map[player].b1; 216 b2 = key_map[player].b2; 217 b3 = key_map[player].b3; 218 b3 = key_map[player].b4; 219 219 } 220 220 … … 235 235 int get_keycode(char const *str) 236 236 { 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 } 237 if( !str[0] ) 238 { 239 return -1; 240 } 241 else if( !str[1] ) 242 { 243 return str[0]; 244 } 245 else 246 { 247 int j; 248 char buf[20]; 249 for( j = 256; j < JK_MAX_KEY; j++ ) 250 { 251 key_name( j, buf ); 252 char *c = buf; 253 for( ; *c; c++ ) 254 { 255 if( *c == ' ' ) 256 { 257 *c = '_'; 258 } 259 else 260 { 261 *c = tolower( *c ); 262 } 263 } 264 if( strcmp( str, buf ) == 0 ) 265 { 266 return j; 267 } 268 } 269 } 270 return -1; 271 } -
abuse/trunk/src/console.cpp
r106 r124 39 39 for (i=0,dx=wx();i<w;i++,s++,dx+=xa) 40 40 { 41 42 41 if (*s) 42 fnt->put_char(con_win->screen,dx,dy,*s); 43 43 } 44 44 } … … 104 104 int dx=wx()+x*fw,dy=wy()+y*fh; 105 105 con_win->screen->bar(dx,dy,dx+fw-1,dy+fh-1,wm->black()); 106 fnt->put_char(con_win->screen,dx,dy,ch); 106 fnt->put_char(con_win->screen,dx,dy,ch); 107 107 } 108 108 } … … 112 112 if (cx<w && cy<h) draw_char(cx,cy,screen[cy*w+cx]); 113 113 cx=0; 114 cy++; 114 cy++; 115 115 if (cy>=h) 116 116 { … … 123 123 wm->flush_screen(); 124 124 } 125 } else draw_cursor(); 125 } else draw_cursor(); 126 126 } 127 127 … … 129 129 { 130 130 131 131 132 132 switch (ch) 133 133 { … … 136 136 if (cx) 137 137 { 138 139 140 141 142 138 if (con_win) 139 draw_char(cx,cy,screen[cy*w+cx]); 140 cx--; 141 if (con_win) 142 draw_cursor(); 143 143 } 144 144 } break; … … 154 154 draw_char(cx,cy,ch); 155 155 cx++; 156 if (cx>=w) do_cr(); else 156 if (cx>=w) do_cr(); else 157 157 if (con_win) draw_cursor(); 158 158 } 159 } 159 } 160 160 } 161 161 … … 198 198 case EV_KEY : 199 199 { 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 200 switch (ev.key) 201 { 202 case JK_BACKSPACE: 203 { 204 if (shcmd[0]!=0) 205 { 206 shcmd[strlen(shcmd)-1]=0; 207 put_char(ev.key); 208 } 209 } break; 210 case JK_ENTER : 211 { 212 put_char(ev.key); 213 execute(shcmd); 214 prompt(); 215 shcmd[0]=0; 216 } break; 217 default : 218 { 219 if (ev.key<256 && isprint(ev.key)) 220 { 221 int x=strlen(shcmd); 222 shcmd[x+1]=0; 223 shcmd[x]=ev.key; 224 put_char(ev.key); 225 } 226 } break; 227 } break; 228 228 } 229 229 } 230 230 return 1; 231 } 231 } 232 232 return 0; 233 233 } -
abuse/trunk/src/control.cpp
r56 r124 24 24 25 25 void controlled_character::note_hp_change(int new_hp, game_object *who) 26 { 27 if (cur_char==who) 28 the_game->set_hit_points(hp); 26 { 27 if (cur_char==who) 28 the_game->set_hit_points(hp); 29 29 } 30 30 … … 34 34 /* switch (char_type) 35 35 { 36 case CHAR_HUMAN : my_figure=human_figure; curbreak; 36 case CHAR_HUMAN : my_figure=human_figure; curbreak; 37 37 case CHAR_IGUANA : my_figure=iguana_figure; break; 38 38 default : CONDITION(0,"change_character, bad character type\n"); … … 40 40 cur_char=char_type; 41 41 set_state(stopped); 42 42 43 43 the_game->change_logos(abilities,cur_char);*/ 44 45 } 44 45 } 46 46 47 47 48 48 49 49 50 50 controlled_character::controlled_character(game_object *who) 51 51 { 52 52 cur_char=who; 53 abilities=0; 53 abilities=0; 54 54 morphing_to=-1; 55 55 } … … 60 60 int button,c_x,c_y; 61 61 the_game->get_movement(button,c_x,c_y); 62 cur_char->move(c_x,c_y,button); 62 cur_char->move(c_x,c_y,button); 63 63 return 1; 64 64 } -
abuse/trunk/src/control.hpp
r57 r124 34 34 void change_character(int char_type); 35 35 36 public : 36 public : 37 37 controlled_character(long X, long Y); 38 38 controlled_character(FILE *fp); -
abuse/trunk/src/cop.cpp
r123 r124 34 34 { 17,20, // 1 35 35 17,23, // 2 36 17,28, 37 15,33, 36 17,28, 37 15,33, 38 38 11,39, // 5 39 39 7,43, 40 40 -3,44, // 7 41 -10,42, 41 -10,42, 42 42 -16,39, 43 43 -20,34, … … 82 82 15,18, 83 83 16,21 }; 84 84 85 85 86 86 enum { in_climbing_area, 87 88 89 90 91 92 93 94 95 87 disable_top_draw, 88 just_hit, 89 ship_pan_x, 90 special_power, 91 used_special_power, 92 last1_x, last1_y, 93 last2_x, last2_y, 94 has_saved_this_level, 95 r_ramp, g_ramp, b_ramp, 96 96 is_teleporting, 97 97 just_fired}; … … 112 112 HEALTH_POWER } ; 113 113 114 enum { top_point_angle, 115 top_fire_delay1, 114 enum { top_point_angle, 115 top_fire_delay1, 116 116 top_just_fired }; 117 117 … … 135 135 game_object *o=current_object; 136 136 if (o->total_objects()) // make sure we are linked to the main character 137 { 137 { 138 138 game_object *q=o->get_object(0); 139 139 … … 143 143 if (!v->freeze_time) 144 144 { 145 146 147 145 o->direction=1; // always face right 146 147 if (q->direction<0) 148 148 q->x+=4; 149 int i; 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 149 int i; 150 signed char *fire_off=o->otype==S_DFRIS_TOP ? large_fire_off : 151 (o->otype==S_ROCKET_TOP ? large_fire_off : 152 (o->otype==S_BFG_TOP ? large_fire_off : small_fire_off)); 153 signed char *f=fire_off,*fb=NULL; 154 int best_diff=200,best_num=0; 155 int iy=f[1],ix=f[6*2]; 156 157 int best_angle=lisp_atan2(q->y-iy-v->pointer_y,v->pointer_x-q->x-ix); 158 for (i=0;i<24;i++,f+=2) // check all the angles to see which would best fit animation wise 159 { 160 int this_angle=lisp_atan2(f[1]-iy,f[0]-ix); 161 int this_diff=angle_diff(this_angle,best_angle); 162 if (this_diff<best_diff) 163 { 164 best_diff=this_diff; 165 best_num=i; 166 fb=f; 167 } 168 } 169 170 171 // if the pointer is too close to the player go with the angle shown, not the angle through the pointer 172 if (abs(q->y-fb[1]-v->pointer_y)<45 & abs(v->pointer_x-q->x+fb[0])<40) 173 o->lvars[point_angle]=lisp_atan2(fb[1]-iy,fb[0]-ix); 174 else 175 o->lvars[point_angle]=lisp_atan2(q->y-fb[1]-v->pointer_y,v->pointer_x-(q->x+fb[0])); 176 177 178 if (q->direction<0) 179 179 q->x-=4; 180 180 181 182 183 184 185 186 187 188 189 190 191 o->otype=weapon_types[v->current_weapon]; // switch to correct top part 181 o->x=q->x; 182 o->y=q->y+29-q->picture()->height(); 183 184 rand_on+=o->lvars[point_angle]; 185 o->current_frame=best_num; 186 187 188 if (o->lvars[fire_delay1]) 189 o->lvars[fire_delay1]--; 190 191 o->otype=weapon_types[v->current_weapon]; // switch to correct top part 192 192 } 193 193 } … … 207 207 int firex=other->x+fire_off[o->current_frame*2]; 208 208 int firey=other->y-fire_off[o->current_frame*2+1];