home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / RAYCAST.ZIP / FILESPR.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-19  |  4.2 KB  |  164 lines

  1. #include "ray.h"
  2. #include "globals.h"
  3. #include "rayfile.h"
  4. #include "resnames.h"
  5. #include "rayspr.h"
  6. #include "utils.h"
  7. #include "sprfunc.h"
  8. #include "fixed.h"
  9.  
  10. void Clear_Obj_Types();
  11.  
  12. BOOL obj_types_loaded=FALSE;
  13.  
  14. void F_Get_Object_Types()
  15. {
  16.  
  17.    if (obj_types_loaded)
  18.       Clear_Obj_Types();
  19.    obj_types_loaded=TRUE;
  20.  
  21.    short dir_index=F_Find_And_Setup((PCHAR)OBJECT_TYPE_RES,
  22.         (void * *)&Obj_Type_List, sizeof(object_type));
  23.    if (dir_index==-1)
  24.       return;
  25.  
  26.    Number_Of_OTs=directory[dir_index].length;
  27.  
  28.    Clear_Objects();
  29.  
  30.    short counter, cur_texture;
  31.    object_type * cur_obj_type;
  32.    short temp_short;
  33.    long extra_data_offset, cur_pos;
  34.  
  35.    for (counter=0; counter<Number_Of_OTs; counter++) {
  36.  
  37.       cur_obj_type=Obj_Type_List+counter;
  38.  
  39.       F_Get_ULong(cur_obj_type->obj_class);
  40.  
  41.       F_Get_Short(cur_obj_type->stats.total_health);
  42.       F_Get_Short(cur_obj_type->stats.base_speed);
  43.       F_Get_Long(cur_obj_type->stats.sight_dis);
  44.       cur_obj_type->stats.other_stats=NULL;
  45.  
  46.       F_Get_UShort(cur_obj_type->angle_num);
  47.    
  48.       cur_obj_type->frames=(ptexture *)NewPtr((cur_obj_type->angle_num) * sizeof(ptexture));
  49.       cur_obj_type->rev_frames=(BOOL *)NewPtr((cur_obj_type->angle_num) * sizeof(BOOL));
  50.       for (cur_texture=0; cur_texture < cur_obj_type->angle_num ; cur_texture++) {
  51.          F_Get_Short(cur_obj_type->frames[cur_texture]);
  52.          F_Get_Short(temp_short);
  53.          if (temp_short==0)
  54.             cur_obj_type->rev_frames[cur_texture]=FALSE;
  55.          else cur_obj_type->rev_frames[cur_texture]=TRUE;
  56.       } /* endfor */
  57.  
  58.       F_Get_UShort(cur_obj_type->width);
  59.       F_Get_UShort(cur_obj_type->height);
  60.       F_Get_UShort(cur_obj_type->eye_height);
  61.       F_Get_UShort(cur_obj_type->stepping_height);
  62.       F_Get_Short(temp_short);
  63.       cur_obj_type->obj_width=convtoMYFIXED(temp_short);
  64.       F_Get_Short(temp_short);
  65.       cur_obj_type->block_width=convtoMYFIXED(temp_short);
  66.  
  67.       // setup various fields used for rendering
  68.  
  69.       cur_obj_type->half_angle=ANGLE_360/(cur_obj_type->angle_num*2);
  70.       cur_obj_type->wshift=Check2Shift(cur_obj_type->width);
  71.       cur_obj_type->hshift=Check2Shift(cur_obj_type->height);
  72.       if (cur_obj_type->wshift > cur_obj_type->hshift) {
  73.          cur_obj_type->wh_ratio=cur_obj_type->wshift - cur_obj_type->hshift;
  74.       } else {
  75.          cur_obj_type->wh_ratio=cur_obj_type->hshift - cur_obj_type->wshift;
  76.       }
  77.  
  78.       F_Get_Short(temp_short);
  79.  
  80.       cur_obj_type->Update_Z=Get_Update_Z_Func(temp_short);
  81.  
  82.       F_Get_Short(temp_short);
  83.  
  84.       cur_obj_type->Load_Extra=Get_Load_Extra_Func(temp_short);
  85.  
  86.       F_Get_Short(temp_short);
  87.  
  88.       cur_obj_type->Update=Get_Update_Func(temp_short);
  89.  
  90.       F_Get_Short(temp_short);
  91.  
  92.       cur_obj_type->Message_Func=Get_Message_Func(temp_short);
  93.  
  94.       F_Get_Short(temp_short);
  95.  
  96.       cur_obj_type->Render_Func=Get_Render_Func(temp_short);
  97.  
  98.       F_Get_Short(temp_short);
  99.  
  100.       cur_obj_type->Render_Data_Loader=Get_Render_Data_Loader(temp_short);
  101.  
  102.       F_Get_Long(extra_data_offset);
  103.  
  104.       cur_pos=F_Abs_Pos();
  105.  
  106.       cur_obj_type->Render_Data_Loader(cur_obj_type, extra_data_offset);
  107.  
  108.       F_Seek_Abs(cur_pos);
  109.  
  110.    } /* endfor */
  111.  
  112. }
  113.  
  114. void F_Get_Objects()
  115. {
  116.    short dir_index=F_Find_Dir((PCHAR)OBJECT_RES);
  117.    if (dir_index==-1)
  118.       return;
  119.  
  120.    long object_count=directory[dir_index].length;
  121.    F_Seek(directory[dir_index].start);
  122.  
  123.    short counter, type;
  124.    long x, y, z;
  125.    ULONG team;
  126.    angle_type angle;
  127.    pobject cur_object;
  128.    long extra_data_offset, cur_pos;
  129.  
  130.    Clear_Objects();
  131.  
  132.    for (counter=0; counter<object_count; counter++) {
  133.  
  134.       F_Get_Long(x);
  135.       F_Get_Long(y);
  136.       F_Get_Long(z);
  137.       F_Get_Long(angle);
  138.       F_Get_Short(type);
  139.       F_Get_ULong(team);
  140.  
  141.       cur_object=Create_Object(x<<SHIFT,y<<SHIFT,z,angle,type,NULL, team);
  142.  
  143.       // was an invalid object created
  144.       if (cur_object==NULL)
  145.          continue;
  146.  
  147.       F_Get_Long(extra_data_offset);
  148.  
  149.       cur_pos=F_Abs_Pos();
  150.  
  151.       cur_object->type->Load_Extra(cur_object, extra_data_offset);
  152.  
  153.       F_Seek_Abs(cur_pos);
  154.  
  155.    } /* endfor */
  156.  
  157. }
  158.  
  159. void Clear_Obj_Types() {
  160.    DelPtr( Obj_Type_List);
  161.    obj_types_loaded=FALSE;
  162. }
  163.  
  164.