Skip to content

Commit

Permalink
Add v1.08 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LB-- committed Nov 14, 2013
1 parent ea304c2 commit ea62c38
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Ext.def
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@ EXPORTS
GetDebugItem @111
EditDebugItem @112

GetRegID @113
SaveRunObject @113
LoadRunObject @114

GetRegID @115
6 changes: 3 additions & 3 deletions Ext.rc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#ifndef _MAC

1 VERSIONINFO
FILEVERSION 1,7,0,0
PRODUCTVERSION 1,7,0,0
FILEVERSION 1,8,0,0
PRODUCTVERSION 1,8,0,0
FILEFLAGSMASK 0x0L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -36,7 +36,7 @@ BEGIN
BLOCK "080004e4"
BEGIN
VALUE "FileDescription", "Value-Add Object For Clickteam's MMF2"
VALUE "FileVersion", "v1.07.0"
VALUE "FileVersion", "v1.08.0"
VALUE "LegalCopyright", "Copyright � 2008-2010 Dynamic Arcade"
VALUE "OriginalFilename", "ValueAdd.mfx"
END
Expand Down
6 changes: 4 additions & 2 deletions Information.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
// Change N,O,N,E to 4 unique characters (MMF currently still uses this to keep track)
#define IDENTIFIER MAKEID(D,A,V,A)

// Version 1.07.0
#define VERSION 170
// Version 1.08.0
#define VERSION 180

#define SAVEDATAVERSION 1

// --------------------
// Version information
Expand Down
139 changes: 139 additions & 0 deletions Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,145 @@ short WINAPI DLLExport ContinueRunObject(LPRDATA rdPtr)
return 0;
}

// -----------------
// SaveRunObject
// -----------------
// Saves the object to disk
//
BOOL WINAPI SaveRunObject(LPRDATA rdPtr, HANDLE hf)
{
BOOL bOK = FALSE;

#ifndef VITALIZE

do
{
DWORD dwBytesWritten;
BOOL WriteSuccess;

WORD SaveVersion = SAVEDATAVERSION;
WriteSuccess = WriteFile(hf, &SaveVersion, sizeof(SaveVersion), &dwBytesWritten, NULL);
if (!WriteSuccess) break;

WORD SavedObjects = rdPtr->pVariableMap->size();
WriteSuccess = WriteFile(hf, &SavedObjects, sizeof(SavedObjects), &dwBytesWritten, NULL);
if (!WriteSuccess) break;

variable_map::iterator i = rdPtr->pVariableMap->begin();
for (i; i != rdPtr->pVariableMap->end(); i++)
{
unsigned int ObjectID = i->first;
WriteSuccess = WriteFile(hf, &ObjectID, sizeof(ObjectID), &dwBytesWritten, NULL);
if (!WriteSuccess) break;

WORD SavedValues = i->second.size();
WriteSuccess = WriteFile(hf, &SavedValues, sizeof(SavedValues), &dwBytesWritten, NULL);
if (!WriteSuccess) break;

variables::iterator j = i->second.begin();
for (j; j != i->second.end(); j++)
{
WORD ValueNameLength = j->first.size();
WriteSuccess = WriteFile(hf, &ValueNameLength, sizeof(ValueNameLength), &dwBytesWritten, NULL);
if (!WriteSuccess) break;

const char* ValueName = j->first.c_str();
WriteSuccess = WriteFile(hf, ValueName, ValueNameLength, &dwBytesWritten, NULL);
if (!WriteSuccess) break;

float Value = j->second;
WriteSuccess = WriteFile(hf, &Value, sizeof(Value), &dwBytesWritten, NULL);
if (!WriteSuccess) break;
}
}
if (!WriteSuccess) break;

bOK = TRUE;
}
while(false);

#endif // VITALIZE

return bOK;
}

// -----------------
// LoadRunObject
// -----------------
// Loads the object from disk
//
BOOL WINAPI LoadRunObject(LPRDATA rdPtr, HANDLE hf)
{
BOOL bOK=FALSE;

#ifndef VITALIZE

do
{
DWORD dwBytesRead;
BOOL ReadSuccess;

WORD SaveVersion;
ReadSuccess = ReadFile(hf, &SaveVersion, sizeof(SaveVersion), &dwBytesRead, NULL);
if (!ReadSuccess) break;

if (SaveVersion != SAVEDATAVERSION)
{
ReadSuccess = false;
break;
}

WORD SavedObjects;
ReadSuccess = ReadFile(hf, &SavedObjects, sizeof(SavedObjects), &dwBytesRead, NULL);
if (!ReadSuccess) break;

rdPtr->pVariableMap->clear();

variable_map::iterator it = rdPtr->pVariableMap->begin();
for (int i = 0; i < SavedObjects; i++)
{
unsigned int ObjectID;
ReadSuccess = ReadFile(hf, &ObjectID, sizeof(ObjectID), &dwBytesRead, NULL);
if (!ReadSuccess) break;

it = rdPtr->pVariableMap->insert( it, objvar_pair(ObjectID, variables()) );

WORD SavedValues;
ReadSuccess = ReadFile(hf, &SavedValues, sizeof(SavedValues), &dwBytesRead, NULL);
if (!ReadSuccess) break;

variables::iterator jt = it->second.begin();
for (int j = 0; j < SavedValues; j++)
{
WORD ValueNameLength;
ReadSuccess = ReadFile(hf, &ValueNameLength, sizeof(ValueNameLength), &dwBytesRead, NULL);
if (!ReadSuccess) break;

string ValueName;
ValueName.resize(ValueNameLength);
ReadSuccess = ReadFile(hf, &ValueName[0], ValueNameLength, &dwBytesRead, NULL);
if (!ReadSuccess) break;

float Value;
ReadSuccess = ReadFile(hf, &Value, sizeof(Value), &dwBytesRead, NULL);
if (!ReadSuccess) break;

jt = it->second.insert( jt, variable(ValueName, Value) );
}
}
if (!ReadSuccess) break;

bOK = TRUE;
}
while(false);

#endif // VITALIZE

return bOK;
}




// ============================================================================
//
Expand Down

0 comments on commit ea62c38

Please sign in to comment.