mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
- fixed: object pointers as array members may not be skipped if they are null.
- changed S_GetMusic to return a const pointer to the actual music name instead of a copy. The only thing this is used for is the savegame code and it has no use for a copy, it can work far more efficiently with a const pointer.
This commit is contained in:
parent
02b3884dff
commit
36bf099d54
4 changed files with 31 additions and 18 deletions
|
@ -528,7 +528,7 @@ void P_SerializeSounds(FSerializer &arc)
|
||||||
|
|
||||||
if (arc.isWriting())
|
if (arc.isWriting())
|
||||||
{
|
{
|
||||||
order = S_GetMusic((char **)&name);
|
order = S_GetMusic(&name);
|
||||||
}
|
}
|
||||||
arc.StringPtr("musicname", name)
|
arc.StringPtr("musicname", name)
|
||||||
("musicorder", order);
|
("musicorder", order);
|
||||||
|
@ -539,7 +539,6 @@ void P_SerializeSounds(FSerializer &arc)
|
||||||
if (level.cdtrack == 0 || !S_ChangeCDMusic(level.cdtrack, level.cdid))
|
if (level.cdtrack == 0 || !S_ChangeCDMusic(level.cdtrack, level.cdid))
|
||||||
S_ChangeMusic(level.Music, level.musicorder);
|
S_ChangeMusic(level.Music, level.musicorder);
|
||||||
}
|
}
|
||||||
delete[] name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -2608,13 +2608,13 @@ void S_MIDIDeviceChanged()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int S_GetMusic (char **name)
|
int S_GetMusic (const char **name)
|
||||||
{
|
{
|
||||||
int order;
|
int order;
|
||||||
|
|
||||||
if (mus_playing.name.IsNotEmpty())
|
if (mus_playing.name.IsNotEmpty())
|
||||||
{
|
{
|
||||||
*name = copystring (mus_playing.name);
|
*name = mus_playing.name;
|
||||||
order = mus_playing.baseorder;
|
order = mus_playing.baseorder;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -334,7 +334,7 @@ void S_RestartMusic ();
|
||||||
|
|
||||||
void S_MIDIDeviceChanged();
|
void S_MIDIDeviceChanged();
|
||||||
|
|
||||||
int S_GetMusic (char **name);
|
int S_GetMusic (const char **name);
|
||||||
|
|
||||||
// Stops the music for sure.
|
// Stops the music for sure.
|
||||||
void S_StopMusic (bool force);
|
void S_StopMusic (bool force);
|
||||||
|
|
|
@ -1514,6 +1514,10 @@ FSerializer &Serialize(FSerializer &arc, const char *key, DObject *&value, DObje
|
||||||
}
|
}
|
||||||
Serialize(arc, key, ndx, nullptr);
|
Serialize(arc, key, ndx, nullptr);
|
||||||
}
|
}
|
||||||
|
else if (!arc.w->inObject())
|
||||||
|
{
|
||||||
|
arc.w->Null();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1524,7 +1528,14 @@ FSerializer &Serialize(FSerializer &arc, const char *key, DObject *&value, DObje
|
||||||
I_Error("Attempt to read object reference without calling ReadObjects first");
|
I_Error("Attempt to read object reference without calling ReadObjects first");
|
||||||
}
|
}
|
||||||
auto val = arc.r->FindKey(key);
|
auto val = arc.r->FindKey(key);
|
||||||
if (val != nullptr && val->IsInt())
|
if (val != nullptr)
|
||||||
|
{
|
||||||
|
if (val->IsNull())
|
||||||
|
{
|
||||||
|
value = nullptr;
|
||||||
|
return arc;
|
||||||
|
}
|
||||||
|
else if (val->IsInt())
|
||||||
{
|
{
|
||||||
int index = val->GetInt();
|
int index = val->GetInt();
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
|
@ -1544,10 +1555,13 @@ FSerializer &Serialize(FSerializer &arc, const char *key, DObject *&value, DObje
|
||||||
Printf(TEXTCOLOR_RED "Invalid object reference for '%s'", key);
|
Printf(TEXTCOLOR_RED "Invalid object reference for '%s'", key);
|
||||||
value = nullptr;
|
value = nullptr;
|
||||||
arc.mErrors++;
|
arc.mErrors++;
|
||||||
|
if (retcode) *retcode = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return arc;
|
||||||
}
|
}
|
||||||
else if (!retcode)
|
}
|
||||||
|
if (!retcode)
|
||||||
{
|
{
|
||||||
value = nullptr;
|
value = nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue