Changeset 544 for abuse/trunk
- Timestamp:
- Apr 28, 2011, 1:07:39 AM (12 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/game.cpp
r541 r544 1339 1339 } 1340 1340 1341 extern void fast_load_start_recording(char *name);1342 extern void fast_load_stop_recording();1343 extern void fast_load_start_reloading(char *name);1344 extern void fast_load_stop_reloading();1345 1346 1341 Game::Game(int argc, char **argv) 1347 1342 { … … 1384 1379 else has_joystick = 0; 1385 1380 1381 // Clean up that old crap 1382 char *fastpath = (char *)malloc(strlen(get_save_filename_prefix()) + 13); 1383 sprintf(fastpath, "%sfastload.dat", get_save_filename_prefix()); 1384 unlink(fastpath); 1385 free(fastpath); 1386 1386 1387 // ProfilerInit(collectDetailed, bestTimeBase, 2000, 200); //prof 1387 char *fastpath;1388 fastpath = (char *)malloc(strlen(get_save_filename_prefix()) + 12 + 1);1389 sprintf(fastpath, "%sfastload.dat", get_save_filename_prefix());1390 fast_load_start_recording(fastpath);1391 1388 load_data(argc, argv); 1392 fast_load_stop_recording();1393 free(fastpath);1394 1389 // ProfilerDump("\pabuse.prof"); //prof 1395 1390 // ProfilerTerm(); -
abuse/trunk/src/imlib/specs.cpp
r542 r544 68 68 static spec_directory spec_main_sd; 69 69 70 static int fast_load_fd = -1;71 static int fast_load_mode = 0;72 73 70 void set_filename_prefix(char const *prefix) 74 71 { … … 280 277 } 281 278 282 void fast_load_start_recording(char *filename)283 {284 fast_load_fd = ::open(filename,O_CREAT|O_RDWR,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);285 fast_load_mode = 1;286 }287 288 void fast_load_stop_recording()289 {290 fast_load_mode = 0;291 }292 293 void fast_load_start_reloading(char *filename)294 {295 fast_load_fd = ::open(filename,O_RDONLY);296 fast_load_mode = 2;297 }298 299 void fast_load_stop_reloading()300 {301 fast_load_mode = 0;302 }303 304 279 jFILE::jFILE(FILE *file_pointer) // assumes fp is at begining of file 305 280 { … … 475 450 if (fd == spec_main_fd) 476 451 { 477 switch (fast_load_mode) 478 { 479 case 0: 480 if (current_offset+start_offset != spec_main_offset) 481 spec_main_offset = lseek(fd, start_offset+current_offset, SEEK_SET); 482 483 len = ::read(fd,(char*)buf,count); 484 break; 485 case 1: 486 if (current_offset+start_offset != spec_main_offset) 487 spec_main_offset = lseek(fd, start_offset+current_offset, SEEK_SET); 488 489 len = ::read(fd,(char*)buf,count); 490 ::write(fast_load_fd,(char*)&len,sizeof(len)); 491 ::write(fast_load_fd,(char*)buf,len); 492 break; 493 case 2: 494 ::read(fast_load_fd,(char*)&len,sizeof(len)); 495 len = ::read(fast_load_fd,(char*)buf,len); 496 break; 497 } 498 452 if (current_offset+start_offset != spec_main_offset) 453 spec_main_offset = lseek(fd, start_offset+current_offset, SEEK_SET); 454 455 len = ::read(fd,(char*)buf,count); 499 456 spec_main_offset += len; 500 457 } 501 458 else 502 459 { 503 switch (fast_load_mode) 504 { 505 case 0: 506 len = ::read(fd,(char*)buf,count); 507 break; 508 case 1: 509 len = ::read(fd,(char*)buf,count); 510 ::write(fast_load_fd,(char*)&len,sizeof(len)); 511 ::write(fast_load_fd,(char*)buf,len); 512 break; 513 case 2: 514 ::read(fast_load_fd,(char*)&len,sizeof(len)); 515 len = ::read(fast_load_fd,(char*)buf,len); 516 if (count != len) 517 printf("short read! %ld:%ld\n",current_offset,len); 518 break; 519 } 460 len = ::read(fd,(char*)buf,count); 520 461 } 521 462 current_offset += len; … … 533 474 { 534 475 long ret; 535 536 if (fast_load_mode == 2)537 {538 switch (whence)539 {540 case SEEK_SET :541 current_offset = start_offset+offset;542 break;543 case SEEK_END :544 current_offset = start_offset+file_length-offset;545 break;546 case SEEK_CUR :547 current_offset += offset;548 break;549 default:550 ret = -1;551 break;552 }553 return current_offset;554 }555 476 556 477 switch (whence)
Note: See TracChangeset
for help on using the changeset viewer.