mirror of https://github.com/OpenTTD/OpenTTD
(svn r16334) -Codechange: use NeedLength enum
parent
88201ccd5c
commit
4876e346d5
|
@ -58,10 +58,16 @@ enum SaveLoadAction {
|
||||||
SLA_SAVE, ///< saving
|
SLA_SAVE, ///< saving
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum NeedLength {
|
||||||
|
NL_NONE = 0, ///< not working in NeedLength mode
|
||||||
|
NL_WANTLENGTH = 1, ///< writing length and data
|
||||||
|
NL_CALCLENGTH = 2, ///< need to calculate the length
|
||||||
|
};
|
||||||
|
|
||||||
/** The saveload struct, containing reader-writer functions, bufffer, version, etc. */
|
/** The saveload struct, containing reader-writer functions, bufffer, version, etc. */
|
||||||
struct SaveLoadParams {
|
struct SaveLoadParams {
|
||||||
SaveLoadAction action; ///< are we doing a save or a load atm.
|
SaveLoadAction action; ///< are we doing a save or a load atm.
|
||||||
byte need_length; ///< ???
|
NeedLength need_length; ///< working in NeedLength (Autolength) mode?
|
||||||
byte block_mode; ///< ???
|
byte block_mode; ///< ???
|
||||||
bool error; ///< did an error occur or not
|
bool error; ///< did an error occur or not
|
||||||
|
|
||||||
|
@ -92,9 +98,6 @@ struct SaveLoadParams {
|
||||||
|
|
||||||
static SaveLoadParams _sl;
|
static SaveLoadParams _sl;
|
||||||
|
|
||||||
|
|
||||||
enum NeedLengthValues {NL_NONE = 0, NL_WANTLENGTH = 1, NL_CALCLENGTH = 2};
|
|
||||||
|
|
||||||
/** Error handler, calls longjmp to simulate an exception.
|
/** Error handler, calls longjmp to simulate an exception.
|
||||||
* @todo this was used to have a central place to handle errors, but it is
|
* @todo this was used to have a central place to handle errors, but it is
|
||||||
* pretty ugly, and seriously interferes with any multithreaded approaches */
|
* pretty ugly, and seriously interferes with any multithreaded approaches */
|
||||||
|
@ -420,10 +423,14 @@ void SlSetLength(size_t length)
|
||||||
SlWriteSparseIndex(_sl.array_index);
|
SlWriteSparseIndex(_sl.array_index);
|
||||||
break;
|
break;
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case NL_CALCLENGTH:
|
case NL_CALCLENGTH:
|
||||||
_sl.obj_len += (int)length;
|
_sl.obj_len += (int)length;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -950,7 +957,7 @@ void SlAutolength(AutolengthProc *proc, void *arg)
|
||||||
{
|
{
|
||||||
size_t offs;
|
size_t offs;
|
||||||
|
|
||||||
assert(_sl.action == SL_SAVE);
|
assert(_sl.action == SLA_SAVE);
|
||||||
|
|
||||||
/* Tell it to calculate the length */
|
/* Tell it to calculate the length */
|
||||||
_sl.need_length = NL_CALCLENGTH;
|
_sl.need_length = NL_CALCLENGTH;
|
||||||
|
|
Loading…
Reference in New Issue