summaryrefslogtreecommitdiff
path: root/saveload.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-18 07:49:25 +0000
committertron <tron@openttd.org>2006-06-18 07:49:25 +0000
commiteba337d51afca4987aa388924380c0a496b43b0d (patch)
treed733e83e2274320198ac90a2673af4db5b486ae3 /saveload.c
parent150b9cb869f2cfcaf55e52e1c3f5f357312718e4 (diff)
downloadopenttd-eba337d51afca4987aa388924380c0a496b43b0d.tar.xz
(svn r5307) Remove two unnecessary indirections which used function pointers instead of directly calling the functions
Diffstat (limited to 'saveload.c')
-rw-r--r--saveload.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/saveload.c b/saveload.c
index 6a75d7955..9e925b2f7 100644
--- a/saveload.c
+++ b/saveload.c
@@ -37,9 +37,6 @@ byte _sl_minor_version; /// the minor savegame version, DO NOT USE!
typedef void WriterProc(uint len);
typedef uint ReaderProc(void);
-typedef uint ReferenceToIntProc(const void *obj, SLRefType rt);
-typedef void *IntToReferenceProc(uint index, SLRefType rt);
-
/** The saveload struct, containing reader-writer functions, bufffer, version, etc. */
static struct {
bool save; /// are we doing a save or a load atm. True when saving
@@ -55,9 +52,6 @@ static struct {
WriterProc *write_bytes; /// savegame writer function
ReaderProc *read_bytes; /// savegame loader function
- ReferenceToIntProc *ref_to_int_proc; /// function to convert pointers to numbers when saving a game
- IntToReferenceProc *int_to_ref_proc; /// function to convert numbers to pointers when loading a game
-
const ChunkHandler* const *chs; /// the chunk of data that is being processed atm (vehicles, signs, etc.)
const SaveLoad* const *includes; /// the internal layouf of the given chunk
@@ -657,6 +651,11 @@ size_t SlCalcObjMemberLength(const SaveLoad *sld)
return 0;
}
+
+static uint ReferenceToInt(const void* obj, SLRefType rt);
+static void* IntToReference(uint index, SLRefType rt);
+
+
bool SlObjectMember(void *ptr, const SaveLoad *sld)
{
VarType conv = GB(sld->conv, 0, 8);
@@ -674,9 +673,10 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld)
case SL_REF: /* Reference variable, translate */
/// @todo XXX - another artificial limitof 65K elements of pointers?
if (_sl.save) { // XXX - read/write pointer as uint16? What is with higher indeces?
- SlWriteUint16(_sl.ref_to_int_proc(*(void**)ptr, conv));
- } else
- *(void**)ptr = _sl.int_to_ref_proc(SlReadUint16(), conv);
+ SlWriteUint16(ReferenceToInt(*(void**)ptr, conv));
+ } else {
+ *(void**)ptr = IntToReference(SlReadUint16(), conv);
+ }
break;
case SL_ARR: SlArray(ptr, sld->length, conv); break;
case SL_STR: SlString(ptr, sld->length, conv); break;
@@ -1490,8 +1490,6 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode)
_sl.bufe = _sl.bufp = NULL;
_sl.offs_base = 0;
- _sl.int_to_ref_proc = IntToReference;
- _sl.ref_to_int_proc = ReferenceToInt;
_sl.save = mode;
_sl.includes = _desc_includes;
_sl.chs = _chunk_handlers;