📄 g_save.pas
字号:
//100%
{$ALIGN ON}{$MINENUMSIZE 4}
{----------------------------------------------------------------------------}
{ }
{ File(s): game\g_save.c }
{ Content: Saving and loading games }
{ }
{ Initial conversion by: Carl A Kenner (carlkenner@hotmail.com) }
{ Initial conversion on: 28-Feb-2002 }
{ }
{ This File contains part of convertion of Quake2 source to ObjectPascal. }
{ More information about this project can be found at: }
{ http://www.sulaco.co.za/quake2/ }
{ }
{ Copyright (C) 1997-2001 Id Software, Inc. }
{ }
{ This program is free software; you can redistribute it and/or }
{ modify it under the terms of the GNU General Public License }
{ as published by the Free Software Foundation; either version 2 }
{ of the License, or (at your option) any later version. }
{ }
{ This program is distributed in the hope that it will be useful, }
{ but WITHOUT ANY WARRANTY; without even the implied warranty of }
{ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. }
{ }
{ See the GNU General Public License for more details. }
{ }
{----------------------------------------------------------------------------}
{ 1) Updated on: 1-Mar-2002 }
{ Updated by: Carl A Kenner }
{ 2) Updated on: 14-May-2003 }
{ Updated by: Scott Price (scott.price@totalise.co.uk) }
{ - Marked 98% as there are some issues requiring investigation }
{ }
{----------------------------------------------------------------------------}
{ * Still dependent (to compile correctly) on: }
{ g_items.InitItems, p_client.SaveClientData }
{----------------------------------------------------------------------------}
{ * TODO: }
{ check for errors }
{ - Check notes in file about areas where additional pointer dereferences }
{ are occuring, and if they are accurate (related to read/write operations }
{ - Check ReadLevel/WriteLevel at some point, as the operations may not be }
{ as intended. Reports of some save files not re-reading inventory }
{ correctly that need to be confirmed and investigated. }
{----------------------------------------------------------------------------}
unit g_save;
interface
uses
q_shared, GameUnit, g_local;
const
__Date__ = 'Mar 01 2002';
var
mmove_reloc: mmove_t;
fields: array[0..80] of field_t;
clientfields: array[0..3] of field_t;
levelfields: array[0..5] of field_t;
procedure InitGame; cdecl;
procedure WriteGame(filename: PChar; autosave: qboolean); cdecl;
procedure ReadGame(filename: PChar); cdecl;
procedure WriteLevel(filename: PChar); cdecl;
procedure ReadLevel(filename: PChar); cdecl;
// CAK - These were originally 4 macros in g_local.h
// But this was the only way to convert them, and because they are so long, I moved them here.
function FOFS_classname: Integer;
function FOFS_model: Integer;
function FOFS_spawnflags: Integer;
function FOFS_speed: Integer;
function FOFS_accel: Integer;
function FOFS_decel: Integer;
function FOFS_target: Integer;
function FOFS_targetname: Integer;
function FOFS_pathtarget: Integer;
function FOFS_deathtarget: Integer;
function FOFS_killtarget: Integer;
function FOFS_combattarget: Integer;
function FOFS_message: Integer;
function FOFS_team: Integer;
function FOFS_wait: Integer;
function FOFS_delay: Integer;
function FOFS_random: Integer;
function FOFS_move_origin: Integer;
function FOFS_move_angles: Integer;
function FOFS_style: Integer;
function FOFS_count: Integer;
function FOFS_health: Integer;
function FOFS_sounds: Integer;
//function FOFS_light: Integer;
function FOFS_dmg: Integer;
function FOFS_mass: Integer;
function FOFS_volume: Integer;
function FOFS_attenuation: Integer;
function FOFS_map: Integer;
function FOFS_s_origin: Integer;
function FOFS_s_angles: Integer;
//function FOFS_s_angles: Integer;
function FOFS_goalentity: Integer;
function FOFS_movetarget: Integer;
function FOFS_enemy: Integer;
function FOFS_oldenemy: Integer;
function FOFS_activator: Integer;
function FOFS_groundentity: Integer;
function FOFS_teamchain: Integer;
function FOFS_teammaster: Integer;
function FOFS_owner: Integer;
function FOFS_mynoise: Integer;
function FOFS_mynoise2: Integer;
function FOFS_target_ent: Integer;
function FOFS_chain: Integer;
function FOFS_prethink: Integer;
function FOFS_think: Integer;
function FOFS_blocked: Integer;
function FOFS_touch: Integer;
function FOFS_use: Integer;
function FOFS_pain: Integer;
function FOFS_die: Integer;
function FOFS_monsterinfo_stand: Integer;
function FOFS_monsterinfo_idle: Integer;
function FOFS_monsterinfo_search: Integer;
function FOFS_monsterinfo_walk: Integer;
function FOFS_monsterinfo_run: Integer;
function FOFS_monsterinfo_dodge: Integer;
function FOFS_monsterinfo_attack: Integer;
function FOFS_monsterinfo_melee: Integer;
function FOFS_monsterinfo_sight: Integer;
function FOFS_monsterinfo_checkattack: Integer;
function FOFS_monsterinfo_currentmove: Integer;
function FOFS_moveinfo_endfunc: Integer;
function FOFS_item: Integer;
function STOFS_lip: Integer;
function STOFS_distance: Integer;
function STOFS_height: Integer;
function STOFS_noise: Integer;
function STOFS_pausetime: Integer;
function STOFS_item: Integer;
function STOFS_gravity: Integer;
function STOFS_sky: Integer;
function STOFS_skyrotate: Integer;
function STOFS_skyaxis: Integer;
function STOFS_minyaw: Integer;
function STOFS_maxyaw: Integer;
function STOFS_minpitch: Integer;
function STOFS_maxpitch: Integer;
function STOFS_nextmap: Integer;
function LLOFS_changemap: Integer;
function LLOFS_sight_client: Integer;
function LLOFS_sight_entity: Integer;
function LLOFS_sound_entity: Integer;
function LLOFS_sound2_entity: Integer;
function CLOFS_pers_weapon: Integer;
function CLOFS_pers_lastweapon: Integer;
function CLOFS_newweapon: Integer;
implementation
uses
SysUtils,
g_main,
g_items, p_client;
// CAK - These were originally 4 macros in g_local.h
// But this was the only way to convert them, and because they are so long, I moved them here.
function FOFS_classname: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.classname); end;
function FOFS_model: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.model); end;
function FOFS_spawnflags: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.spawnflags); end;
function FOFS_speed: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.speed); end;
function FOFS_accel: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.accel); end;
function FOFS_decel: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.decel); end;
function FOFS_target: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.target); end;
function FOFS_targetname: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.targetname); end;
function FOFS_pathtarget: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.pathtarget); end;
function FOFS_deathtarget: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.deathtarget); end;
function FOFS_killtarget: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.killtarget); end;
function FOFS_combattarget: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.combattarget); end;
function FOFS_message: Integer; begin Result:=Integer(@edict_p(Ptr(0))^._message); end;
function FOFS_team: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.team); end;
function FOFS_wait: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.wait); end;
function FOFS_delay: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.delay); end;
function FOFS_random: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.random); end;
function FOFS_move_origin: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.move_origin); end;
function FOFS_move_angles: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.move_angles); end;
function FOFS_style: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.style); end;
function FOFS_count: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.count); end;
function FOFS_health: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.health); end;
function FOFS_sounds: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.sounds); end;
//function FOFS_light: Integer; begin Result:=Integer(@edict_p(Ptr(0)).light); end;
function FOFS_dmg: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.dmg); end;
function FOFS_mass: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.mass); end;
function FOFS_volume: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.volume); end;
function FOFS_attenuation: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.attenuation); end;
function FOFS_map: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.map); end;
function FOFS_s_origin: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.s.origin); end;
function FOFS_s_angles: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.s.angles); end;
//function FOFS_s_angles: Integer; begin Result:=Integer(@edict_p(Ptr(0)).s.angles); end;
function FOFS_goalentity: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.goalentity); end;
function FOFS_movetarget: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.movetarget); end;
function FOFS_enemy: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.enemy); end;
function FOFS_oldenemy: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.oldenemy); end;
function FOFS_activator: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.activator); end;
function FOFS_groundentity: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.groundentity); end;
function FOFS_teamchain: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.teamchain); end;
function FOFS_teammaster: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.teammaster); end;
function FOFS_owner: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.owner); end;
function FOFS_mynoise: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.mynoise); end;
function FOFS_mynoise2: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.mynoise2); end;
function FOFS_target_ent: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.target_ent); end;
function FOFS_chain: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.chain); end;
function FOFS_prethink: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.prethink); end;
function FOFS_think: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.think); end;
function FOFS_blocked: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.blocked); end;
function FOFS_touch: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.touch); end;
function FOFS_use: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.use); end;
function FOFS_pain: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.pain); end;
function FOFS_die: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.die); end;
function FOFS_monsterinfo_stand: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.stand); end;
function FOFS_monsterinfo_idle: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.idle); end;
function FOFS_monsterinfo_search: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.search); end;
function FOFS_monsterinfo_walk: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.walk); end;
function FOFS_monsterinfo_run: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.run); end;
function FOFS_monsterinfo_dodge: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.dodge); end;
function FOFS_monsterinfo_attack: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.attack); end;
function FOFS_monsterinfo_melee: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.melee); end;
function FOFS_monsterinfo_sight: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.sight); end;
function FOFS_monsterinfo_checkattack: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.monsterinfo.checkattack); end;
function FOFS_monsterinfo_currentmove: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.monsterinfo.currentmove); end;
function FOFS_moveinfo_endfunc: Integer; begin Result:=Integer(@@edict_p(Ptr(0))^.moveinfo.endfunc); end;
function FOFS_item: Integer; begin Result:=Integer(@edict_p(Ptr(0))^.item); end;
function STOFS_lip: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.lip); end;
function STOFS_distance: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.distance); end;
function STOFS_height: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.height); end;
function STOFS_noise: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.noise); end;
function STOFS_pausetime: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.pausetime); end;
function STOFS_item: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.item); end;
function STOFS_gravity: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.gravity); end;
function STOFS_sky: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.sky); end;
function STOFS_skyrotate: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.skyrotate); end;
function STOFS_skyaxis: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.skyaxis); end;
function STOFS_minyaw: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.minyaw); end;
function STOFS_maxyaw: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.maxyaw); end;
function STOFS_minpitch: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.minpitch); end;
function STOFS_maxpitch: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.maxpitch); end;
function STOFS_nextmap: Integer; begin Result:=Integer(@spawn_temp_p(Ptr(0))^.nextmap); end;
function LLOFS_changemap: Integer; begin Result:=Integer(@level_locals_p(Ptr(0))^.changemap); end;
function LLOFS_sight_client: Integer; begin Result:=Integer(@level_locals_p(Ptr(0))^.sight_client); end;
function LLOFS_sight_entity: Integer; begin Result:=Integer(@level_locals_p(Ptr(0))^.sight_entity); end;
function LLOFS_sound_entity: Integer; begin Result:=Integer(@level_locals_p(Ptr(0))^.sound_entity); end;
function LLOFS_sound2_entity: Integer; begin Result:=Integer(@level_locals_p(Ptr(0))^.sound2_entity); end;
function CLOFS_pers_weapon: Integer; begin Result:=Integer(@gclient_p(Ptr(0))^.pers.weapon); end;
function CLOFS_pers_lastweapon: Integer; begin Result:=Integer(@gclient_p(Ptr(0))^.pers.lastweapon); end;
function CLOFS_newweapon: Integer; begin Result:=Integer(@gclient_p(Ptr(0))^.newweapon); end;
procedure SetFields;
begin
with fields[0] do begin
name:='classname'; ofs:= FOFS_classname; _type:= F_LSTRING;
end;
with fields[1] do begin
name:='model'; ofs:= FOFS_model; _type:= F_LSTRING;
end;
with fields[2] do begin
name:='spawnflags'; ofs:= FOFS_spawnflags; _type:= F_INT;
end;
with fields[3] do begin
name:='speed'; ofs:= FOFS_speed; _type:= F_FLOAT;
end;
with fields[4] do begin
name:='accel'; ofs:= FOFS_accel; _type:= F_FLOAT;
end;
with fields[5] do begin
name:='decel'; ofs:= FOFS_decel; _type:= F_FLOAT;
end;
with fields[6] do begin
name:='target'; ofs:= FOFS_target; _type:= F_LSTRING;
end;
with fields[7] do begin
name:='targetname'; ofs:= FOFS_targetname; _type:= F_LSTRING;
end;
with fields[8] do begin
name:='pathtarget'; ofs:= FOFS_pathtarget; _type:= F_LSTRING;
end;
with fields[9] do begin
name:='deathtarget'; ofs:= FOFS_deathtarget; _type:= F_LSTRING;
end;
with fields[10] do begin
name:='killtarget'; ofs:= FOFS_killtarget; _type:= F_LSTRING;
end;
with fields[11] do begin
name:='combattarget'; ofs:= FOFS_combattarget; _type:= F_LSTRING;
end;
with fields[12] do begin name:='message'; ofs:= FOFS_message; _type:= F_LSTRING; end;
with fields[13] do begin name:='team'; ofs:= FOFS_team; _type:= F_LSTRING; end;
with fields[14] do begin name:='wait'; ofs:= FOFS_wait; _type:= F_FLOAT; end;
with fields[15] do begin name:='delay'; ofs:= FOFS_delay; _type:= F_FLOAT; end;
with fields[16] do begin name:='random'; ofs:= FOFS_random; _type:= F_FLOAT; end;
with fields[17] do begin name:='move_origin'; ofs:= FOFS_move_origin; _type:= F_VECTOR; end;
with fields[18] do begin name:='move_angles'; ofs:= FOFS_move_angles; _type:= F_VECTOR; end;
with fields[19] do begin name:='style'; ofs:= FOFS_style; _type:= F_INT; end;
with fields[20] do begin name:='count'; ofs:= FOFS_count; _type:= F_INT; end;
with fields[21] do begin name:='health'; ofs:= FOFS_health; _type:= F_INT; end;
with fields[22] do begin name:='sounds'; ofs:= FOFS_sounds; _type:= F_INT; end;
with fields[23] do begin name:='light'; ofs:= 0; _type:= F_IGNORE; end;
with fields[24] do begin name:='dmg'; ofs:= FOFS_dmg; _type:= F_INT; end;
with fields[25] do begin name:='mass'; ofs:= FOFS_mass; _type:= F_INT; end;
with fields[26] do begin name:='volume'; ofs:= FOFS_volume; _type:= F_FLOAT; end;
with fields[27] do begin name:='attenuation'; ofs:= FOFS_attenuation; _type:= F_FLOAT; end;
with fields[28] do begin name:='map'; ofs:= FOFS_map; _type:= F_LSTRING; end;
with fields[29] do begin name:='origin'; ofs:= FOFS_s_origin; _type:= F_VECTOR; end;
with fields[30] do begin name:='angles'; ofs:= FOFS_s_angles; _type:= F_VECTOR; end;
with fields[31] do begin name:='angle'; ofs:= FOFS_s_angles; _type:= F_ANGLEHACK; end;
with fields[32] do begin name:='goalentity'; ofs:= FOFS_goalentity; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[33] do begin name:='movetarget'; ofs:= FOFS_movetarget; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[34] do begin name:='enemy'; ofs:= FOFS_enemy; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[35] do begin name:='oldenemy'; ofs:= FOFS_oldenemy; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[36] do begin name:='activator'; ofs:= FOFS_activator; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[37] do begin name:='groundentity'; ofs:= FOFS_groundentity; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[38] do begin name:='teamchain'; ofs:= FOFS_teamchain; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[39] do begin name:='teammaster'; ofs:= FOFS_teammaster; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[40] do begin name:='owner'; ofs:= FOFS_owner; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[41] do begin name:='mynoise'; ofs:= FOFS_mynoise; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[42] do begin name:='mynoise2'; ofs:= FOFS_mynoise2; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[43] do begin name:='target_ent'; ofs:= FOFS_target_ent; _type:= F_EDICT; flags:= FFL_NOSPAWN; end;
with fields[44] do begin
name:='chain';
ofs:= FOFS_chain;
_type:= F_EDICT;
flags:= FFL_NOSPAWN;
end;
with fields[45] do begin
name:='prethink';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -