Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tzachshabtay committed Apr 4, 2013
2 parents e64c0ef + 9fc9417 commit f0842cd
Show file tree
Hide file tree
Showing 20 changed files with 180 additions and 97 deletions.
19 changes: 13 additions & 6 deletions Common/ac/gamesetupstructbase.cpp
Expand Up @@ -52,9 +52,16 @@ void GameSetupStructBase::ReadFromFile(Stream *in)
//for (i = 0; i < MAXGLOBALMES; i++)
// messages[i] = (char*)in->ReadInt32();

// The following pointers are used as flags at one point
// during game loading, therefore they are initialized with
// some values here. These values are never treated as
// actual addresses, only as boolean values.
// See:
// - GameSetupStruct::read_words_dictionary(), dict
// - load_game_file(), compiled_script
dict = (WordsDictionary *) in->ReadInt32();
globalscript = (char *) in->ReadInt32();
chars = (CharacterInfo *) in->ReadInt32();
in->ReadInt32(); // globalscript
in->ReadInt32(); // chars
compiled_script = (ccScript *) in->ReadInt32();
}

Expand Down Expand Up @@ -87,8 +94,8 @@ void GameSetupStructBase::WriteToFile(Stream *out)
out->WriteArrayOfInt32(reserved, 17);
// write the final ptrs so we know to load dictionary, scripts etc
out->WriteArrayOfIntPtr32((intptr_t*)messages, MAXGLOBALMES);
out->WriteInt32((int32)dict);
out->WriteInt32((int32)globalscript);
out->WriteInt32((int32)chars);
out->WriteInt32((int32)compiled_script);
out->WriteInt32(dict ? 1 : 0);
out->WriteInt32(0); // globalscript
out->WriteInt32(0); // chars
out->WriteInt32(compiled_script ? 1 : 0);
}
7 changes: 7 additions & 0 deletions Common/ac/gamesetupstructbase.h
Expand Up @@ -64,6 +64,13 @@ struct GameSetupStructBase {
char *globalscript;
CharacterInfo *chars;
ccScript *compiled_script;
// [IKM] 2013-03-30
// NOTE: it looks like nor 'globalscript', not 'compiled_script' are used
// to store actual script data anytime; 'ccScript* gamescript' global
// pointer is used for that instead.
// 'compiled_script' member is used once as a flag, to indicate that there's
// a global script data to be loaded; 'globalscript' is not used anywhere
// for anything useful.

void ReadFromFile(Common::Stream *in);
void WriteToFile(Common::Stream *out);
Expand Down
7 changes: 4 additions & 3 deletions Editor/AGS.Editor/Panes/WelcomePane.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Editor/AGS.Editor/Panes/WelcomePane.resx
Expand Up @@ -124,6 +124,8 @@
* Find where your characters, dialogs, views, inventory items and global variables are used using a simple menu click
* Easy navigation from an open document to its location in the tree using a simple menu click
* New shortcuts in the script editor to navigate to a specific line (Ctrl+G) and switch between header and script (Ctrl+M)
* The engine runs games made with previous versions of AGS as old as 2.5
* Run games with x5, x6 ,x7 or x8 graphics scaling filter
* And loads more!</value>
</data>
</root>
Binary file modified Editor/AGS.Editor/Resources/splash.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion Engine/Makefile-defs.linux
@@ -1,6 +1,6 @@
INCDIR = ../Engine ../Common ../Common/libinclude ../Plugins
LIBDIR =
override CFLAGS += -O2 -pie -fpie -g -fsigned-char -Wfatal-errors -DNDEBUG -DAGS_RUNTIME_PATCH_ALLEGRO -DAGS_HAS_CD_AUDIO -DAGS_CASE_SENSITIVE_FILESYSTEM -DALLEGRO_STATICLINK -DLINUX_VERSION -DDISABLE_MPEG_AUDIO -DBUILTIN_PLUGINS -DRTLD_NEXT $(shell pkg-config --cflags freetype2)
override CFLAGS += -O2 -g -fsigned-char -Wfatal-errors -DNDEBUG -DAGS_RUNTIME_PATCH_ALLEGRO -DAGS_HAS_CD_AUDIO -DAGS_CASE_SENSITIVE_FILESYSTEM -DALLEGRO_STATICLINK -DLINUX_VERSION -DDISABLE_MPEG_AUDIO -DBUILTIN_PLUGINS -DRTLD_NEXT $(shell pkg-config --cflags freetype2)
override CXXFLAGS += -fno-rtti -Wno-write-strings -fpermissive
LIBS = -rdynamic $(shell allegro-config --libs) -laldmb -ldumb -Wl,-Bdynamic -ltheora -logg

Expand Down
15 changes: 8 additions & 7 deletions Engine/ac/dynobj/cc_dynamicobject.cpp
Expand Up @@ -45,8 +45,8 @@ void ccSetStringClassImpl(ICCStringClass *theClass) {

// register a memory handle for the object and allow script
// pointers to point to it
int32_t ccRegisterManagedObject(const void *object, ICCDynamicObject *callback) {
int32_t handl = pool.AddObject((const char*)object, callback);
int32_t ccRegisterManagedObject(const void *object, ICCDynamicObject *callback, bool plugin_object) {
int32_t handl = pool.AddObject((const char*)object, callback, plugin_object);

#ifdef DEBUG_MANAGED_OBJECTS
char bufff[200];
Expand All @@ -58,8 +58,8 @@ int32_t ccRegisterManagedObject(const void *object, ICCDynamicObject *callback)
}

// register a de-serialized object
int32_t ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *callback) {
return pool.AddObject((const char*)object, callback, index);
int32_t ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *callback, bool plugin_object) {
return pool.AddObject((const char*)object, callback, plugin_object, index);
}

// unregister a particular object
Expand Down Expand Up @@ -130,17 +130,18 @@ const char *ccGetObjectAddressFromHandle(int32_t handle) {
return addr;
}

void ccGetObjectAddressAndManagerFromHandle(int32_t handle, void *&object, ICCDynamicObject *&manager)
ScriptValueType ccGetObjectAddressAndManagerFromHandle(int32_t handle, void *&object, ICCDynamicObject *&manager)
{
if (handle == 0) {
object = NULL;
manager = NULL;
return;
return kScValUndefined;
}
pool.HandleToAddressAndManager(handle, object, manager);
ScriptValueType obj_type = pool.HandleToAddressAndManager(handle, object, manager);
if (object == NULL) {
cc_error("Error retrieving pointer: invalid handle %d", handle);
}
return obj_type;
}

int ccAddObjectReference(int32_t handle) {
Expand Down
7 changes: 4 additions & 3 deletions Engine/ac/dynobj/cc_dynamicobject.h
Expand Up @@ -20,6 +20,7 @@
#define __CC_DYNAMICOBJECT_H

#include "util/file.h"
#include "script/runtimescriptvalue.h"

// Forward declaration
namespace AGS { namespace Common { class Stream; } }
Expand Down Expand Up @@ -63,9 +64,9 @@ struct ICCStringClass {
extern void ccSetStringClassImpl(ICCStringClass *theClass);
// register a memory handle for the object and allow script
// pointers to point to it
extern int32_t ccRegisterManagedObject(const void *object, ICCDynamicObject *);
extern int32_t ccRegisterManagedObject(const void *object, ICCDynamicObject *, bool plugin_object = false);
// register a de-serialized object
extern int32_t ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *);
extern int32_t ccRegisterUnserializedObject(int index, const void *object, ICCDynamicObject *, bool plugin_object = false);
// unregister a particular object
extern int ccUnRegisterManagedObject(const void *object);
// remove all registered objects
Expand All @@ -79,7 +80,7 @@ extern void ccAttemptDisposeObject(int32_t handle);
// translate between object handles and memory addresses
extern int32_t ccGetObjectHandleFromAddress(const char *address);
extern const char *ccGetObjectAddressFromHandle(int32_t handle);
extern void ccGetObjectAddressAndManagerFromHandle(int32_t handle, void *&object, ICCDynamicObject *&manager);
extern ScriptValueType ccGetObjectAddressAndManagerFromHandle(int32_t handle, void *&object, ICCDynamicObject *&manager);

extern int ccAddObjectReference(int32_t handle);
extern int ccReleaseObjectReference(int32_t handle);
Expand Down
19 changes: 11 additions & 8 deletions Engine/ac/dynobj/managedobjectpool.cpp
Expand Up @@ -23,7 +23,9 @@

using AGS::Common::Stream;

void ManagedObjectPool::ManagedObject::init(int32_t theHandle, const char *theAddress, ICCDynamicObject *theCallback) {
void ManagedObjectPool::ManagedObject::init(int32_t theHandle, const char *theAddress,
ICCDynamicObject *theCallback, ScriptValueType objType) {
obj_type = objType;
handle = theHandle;
addr = theAddress;
callback = theCallback;
Expand Down Expand Up @@ -137,16 +139,17 @@ const char* ManagedObjectPool::HandleToAddress(int32_t handle) {
return objects[handle].addr;
}

void ManagedObjectPool::HandleToAddressAndManager(int32_t handle, void *&object, ICCDynamicObject *&manager) {
ScriptValueType ManagedObjectPool::HandleToAddressAndManager(int32_t handle, void *&object, ICCDynamicObject *&manager) {
object = NULL;
manager = NULL;
// this function is called often (whenever a pointer is used)
if ((handle < 1) || (handle >= arrayAllocLimit))
return;
return kScValUndefined;
if (objects[handle].handle == 0)
return;
return kScValUndefined;
object = (void*)objects[handle].addr;
manager = objects[handle].callback;
return objects[handle].obj_type;
}

int ManagedObjectPool::RemoveObject(const char *address) {
Expand Down Expand Up @@ -180,15 +183,15 @@ void ManagedObjectPool::RunGarbageCollection()
}
}

int ManagedObjectPool::AddObject(const char *address, ICCDynamicObject *callback, int useSlot) {
int ManagedObjectPool::AddObject(const char *address, ICCDynamicObject *callback, bool plugin_object, int useSlot) {
if (useSlot == -1)
useSlot = numObjects;

objectCreationCounter++;

if (useSlot < arrayAllocLimit) {
// still space in the array, so use it
objects[useSlot].init(useSlot, address, callback);
objects[useSlot].init(useSlot, address, callback, plugin_object ? kScValPluginObject : kScValDynamicObject);
if (useSlot == numObjects)
numObjects++;
return useSlot;
Expand All @@ -201,7 +204,7 @@ int ManagedObjectPool::AddObject(const char *address, ICCDynamicObject *callback
// long
for (int i = arrayAllocLimit - 1; i >= 1; i--) {
if (objects[i].handle == 0) {
objects[i].init(i, address, callback);
objects[i].init(i, address, callback, plugin_object ? kScValPluginObject : kScValDynamicObject);
return i;
}
}
Expand All @@ -212,7 +215,7 @@ int ManagedObjectPool::AddObject(const char *address, ICCDynamicObject *callback

objects = (ManagedObject*)realloc(objects, sizeof(ManagedObject) * arrayAllocLimit);
memset(&objects[useSlot], 0, sizeof(ManagedObject) * ARRAY_INCREMENT_SIZE);
objects[useSlot].init(useSlot, address, callback);
objects[useSlot].init(useSlot, address, callback, plugin_object ? kScValPluginObject : kScValDynamicObject);
if (useSlot == numObjects)
numObjects++;
return useSlot;
Expand Down
8 changes: 5 additions & 3 deletions Engine/ac/dynobj/managedobjectpool.h
Expand Up @@ -27,12 +27,14 @@ const int GARBAGE_COLLECTION_INTERVAL = 100;

struct ManagedObjectPool {
struct ManagedObject {
ScriptValueType obj_type;
int32_t handle;
const char *addr;
ICCDynamicObject * callback;
int refCount;

void init(int32_t theHandle, const char *theAddress, ICCDynamicObject *theCallback);
void init(int32_t theHandle, const char *theAddress,
ICCDynamicObject *theCallback, ScriptValueType objType);
int remove(bool force);
int AddRef();
int CheckDispose();
Expand All @@ -53,11 +55,11 @@ struct ManagedObjectPool {
int32_t SubRef(int32_t handle);
int32_t AddressToHandle(const char *addr);
const char* HandleToAddress(int32_t handle);
void HandleToAddressAndManager(int32_t handle, void *&object, ICCDynamicObject *&manager);
ScriptValueType HandleToAddressAndManager(int32_t handle, void *&object, ICCDynamicObject *&manager);
int RemoveObject(const char *address);
void RunGarbageCollectionIfAppropriate();
void RunGarbageCollection();
int AddObject(const char *address, ICCDynamicObject *callback, int useSlot = -1);
int AddObject(const char *address, ICCDynamicObject *callback, bool plugin_object, int useSlot = -1);
void WriteToDisk(Common::Stream *out);
int ReadFromDisk(Common::Stream *in, ICCObjectReader *reader);
void reset();
Expand Down
6 changes: 2 additions & 4 deletions Engine/ac/game.cpp
Expand Up @@ -1157,10 +1157,10 @@ void save_game_room_state(Stream *out)
out->Write(&roomstat->tsdata[0], roomstat->tsdatasize);
}
else
out->WriteInt8 (0); // <--- [IKM] added by me, CHECKME if needed / works correctly
out->WriteInt8(0);
}
else
out->WriteInt8 (0);
out->WriteInt8(0);
}
}

Expand Down Expand Up @@ -1308,7 +1308,6 @@ void save_game_displayed_room_status(Stream *out)

// save the current troom, in case they save in room 600 or whatever
WriteRoomStatus_Aligned(&troom, out);
//out->WriteArray(&troom,sizeof(RoomStatus),1);
if (troom.tsdatasize>0)
out->Write(&troom.tsdata[0],troom.tsdatasize);

Expand Down Expand Up @@ -1991,7 +1990,6 @@ void restore_game_displayed_room_status(Stream *in, Bitmap **newbscene)
}
else
troom.tsdata = NULL;

}
}

Expand Down
8 changes: 4 additions & 4 deletions Engine/ac/gamestate.cpp
Expand Up @@ -200,8 +200,8 @@ void GameState::ReadFromFile_v321(Stream *in)
gamma_adjustment = in->ReadInt32();
temporarily_turned_off_character = in->ReadInt16();
inv_backwards_compatibility = in->ReadInt16();
gui_draw_order = (int*)in->ReadInt32();
do_once_tokens = (char**)in->ReadInt32();
in->ReadInt32(); // gui_draw_order
in->ReadInt32(); // do_once_tokens;
num_do_once_tokens = in->ReadInt32();
text_min_display_time_ms = in->ReadInt32();
ignore_user_input_after_text_timeout_ms = in->ReadInt32();
Expand Down Expand Up @@ -376,8 +376,8 @@ void GameState::WriteToFile_v321(Stream *out)
out->WriteInt32( gamma_adjustment);
out->WriteInt16(temporarily_turned_off_character);
out->WriteInt16(inv_backwards_compatibility);
out->WriteInt32((int32)gui_draw_order);
out->WriteInt32((int32)do_once_tokens);
out->WriteInt32(0); // gui_draw_order
out->WriteInt32(0); // do_once_tokens
out->WriteInt32( num_do_once_tokens);
out->WriteInt32( text_min_display_time_ms);
out->WriteInt32( ignore_user_input_after_text_timeout_ms);
Expand Down
4 changes: 2 additions & 2 deletions Engine/ac/roomstatus.cpp
Expand Up @@ -28,7 +28,7 @@ void RoomStatus::ReadFromFile_v321(Stream *in)
ReadRoomObjects_Aligned(in);
in->ReadArrayOfInt16(flagstates, MAX_FLAGS);
tsdatasize = in->ReadInt32();
tsdata = (char *) in->ReadInt32();
in->ReadInt32(); // tsdata
for (int i = 0; i < MAX_HOTSPOTS; ++i)
{
intrHotspot[i].ReadFromFile(in);
Expand All @@ -55,7 +55,7 @@ void RoomStatus::WriteToFile_v321(Stream *out)
WriteRoomObjects_Aligned(out);
out->WriteArrayOfInt16(flagstates, MAX_FLAGS);
out->WriteInt32(tsdatasize);
out->WriteInt32((int)tsdata);
out->WriteInt32(0); // tsdata
for (int i = 0; i < MAX_HOTSPOTS; ++i)
{
intrHotspot[i].WriteToFile(out);
Expand Down
4 changes: 2 additions & 2 deletions Engine/media/audio/queuedaudioitem.cpp
Expand Up @@ -26,13 +26,13 @@ void QueuedAudioItem::ReadFromFile(Stream *in)
audioClipIndex = in->ReadInt16();
priority = in->ReadInt16();
repeat = in->ReadBool();
cachedClip = (SOUNDCLIP*)in->ReadInt32();
in->ReadInt32(); // cachedClip
}

void QueuedAudioItem::WriteToFile(Stream *out)
{
out->WriteInt16(audioClipIndex);
out->WriteInt16(priority);
out->WriteBool(repeat);
out->WriteInt32((int32)cachedClip);
out->WriteInt32(0); // cachedClip
}

0 comments on commit f0842cd

Please sign in to comment.