I'm still interested in the MacOS executable though, even with the colors issue 
I can act as a tester if you guys wish.

I can act as a tester if you guys wish.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Crimson Wizard on Wed 13/05/2020 15:02:13That's the complicated stuff. Hundreds and hundreds of copy-and-paste of the same array allocation and deallocation, over the last 15 years. The thing is that people who come from the C++ and C world are so used to it that they don't see it anymore. They accept that 90% of any code is "allocate array, expand array, insert item into array, remove item from array, shrink array". I haven't given up yet.
I would just write a narrow specialized type meant to be used with dedicated functions
Quote from: Crimson Wizard on Wed 13/05/2020 14:38:02That was a shortcut. It would actually be the index of an element stored in an external array of managed structs. Therefore, an int.Quote from: Monsieur OUXX on Wed 13/05/2020 14:32:07
managed struct Pointer {
DynamicSprite* someCompositeDataThatNeedsToHaveACustomDestructor;
};
You won't be able to do exactly this because AGS still does not allow managed pointers inside managed struct.
Quote from: Crimson Wizard on Wed 13/05/2020 14:38:02How about this : An array of arrays of custom structs, each struct containing an array of arrays of int. All of that mess being represented only as ints (that int being the index in the actual array of structs, or array of ints, or array of arrays of ints) since, as you pointed out, AGS won't let you do any of that using pointers.
But still, what kind of actual object that needs custom destructor you are talking about? Can you give an actual example, allowing to understand why AGS's own garbage collection is not suitable?
#define ArbitrarilyComplexType DynamicSprite*
#define ArbitrarilyComplexType_Index int
//Some basic array to store data externally, as AGS doesn't allow managed structs in managed structs
ArbitrarilyComplexType rawData[9999];
#define PointerType int
managed struct Pointer {
PointerType ptrId;
ArbitrarilyComplexType_Index someCompositeDataThatNeedsToHaveACustomDestructor;
};
Pointer* pointers[];
struct PtrFactory {
import static PointerType Constructor(DynamicSprite* data);
import static void Destructor(PointerType ptr);
};
PointerType PtrFactory::Constructor(DynamicSprite* data)
{
Pointer* p = new Pointer;
pointers[index] = p; //(not detailed : create entry in array 'pointers' and get the index)
p.ptrId = index;
rawData[dataIndex] = data; //(not detailed : create entry in array 'rawData' ad get the index)
p.someCompositeDataThatNeedsToHaveACustomDestructor = dataIndex;
return p.ptrId;
}
void PtrFactory::Destructor(PointerType ptr)
{
//Destructor stuff
ArbitrarilyComplexType objectToDestroy = rawData[pointers[ptr].someCompositeDataThatNeedsToHaveACustomDestructor];
objectToDestroy .Delete(); //Whatever needs to be done
pointers[ptr].ptrId = -1;
pointers[ptr] = null;
}
//////////////////////////////////
managed struct Reference {
int count;
PointerType ptr;
};
Reference* refs[];
struct RefFactory {
import static Reference* CreateRef(PointerType ptr);
import static void DestroyRef(Reference*);
import static Reference* CopyRef(Reference*);
};
Reference* RefFactory::CreateRef(PointerType ptr)
{
// find if there's a ref contining 'ptr' in 'refs'.
if (yes) // increase count
refs[existingRef].count ++;
return refs[existingRef];
if (not) //create new ref
refs[newRef] = new Reference;
refs[newRef].count = 1;
refs[newRef].ptr = ptr;
return refs[newRef];
}
void RefFactory::DestroyRef(Reference* ref)
{
for (int i=0; i< refs.length; i++) {
if (refs[i] == ref) {
if (refs[i].count > 1) {
refs[i].count--;
} else if (refs[i].count == 1) {
PtrFactory.Destructor(refs[i].ptr);
refs[i].count = 0;
refs[i] = null;
} else { // 0
AbortGame("All the references to that pointer have already been destroyed. Did you do an illegal copy, you punk?");
}
}
}
}
Reference* RefFactory::CopyRef(Reference* ref)
{
for (int i=0; i< refs.length; i++) {
if (refs[i] == ref) {
refs[i].count++;
return refs[i];
}
}
AbortGame("Cannot copy illegal reference");
}
/////////////////////////////////////////////////////////
void game_start() {
DynamicSprite* someCompositeData = DynamicSprite.Create(); // In the final product, the user would not be allowed to manipulate pointers, they'd be given the factory to create references directly.
PointerType ptr = PtrFactory.Constructor(someCompositeData);
Reference* someLegalRef1 = RefFactory.CreateRef(ptr);
Reference* someLegalRef2 = RefFactory.CreateRef(ptr);
Reference* someLegalRef3 = RefFactory.CopyRef(someLegalRef2);
Reference* someIllegalRef = someLegalRef1; //Allowed syntactically, but shady
RefFactory.DestroyRef(someLegalRef1);
RefFactory.DestroyRef(someLegalRef2);
RefFactory.DestroyRef(someIllegalRef); // Will work because this is technically someLegalRef3. This calls the Destructor of ptr, as expected.
RefFactory.DestroyRef(someLegalRef3); // Was already destroyed just before. Causes an AbortGame;
}
Quote from: Snarky on Wed 13/05/2020 13:18:40
To be more explicit: the "references" could be instances of a managed type.
managed struct Reference {
int pointer;
};
Reference* ref1 = Factory.CreateReference(); //Side-note: What stops me from using "new" and messing up things?
Reference* ref2 = ref1 ; //I now have a copy out there in the wilderness and the garbage collector doesn't know about it.
VariableType copy = ASSIGN(originalVariable);
VariableType copy = originalVariable; //I want this to be forbidden
Quote from: Crimson Wizard on Fri 08/05/2020 10:29:24
So, we need to write a page in the manual explaining all this, ok.
enum eObjectType {
eGizmo, //use this type for regular-sized objects. Usually, objects that the player could physically pick up but doesn't need.
eHeavy, //use this type for objects that are too heavy to pickup/push/pull
eCharacter, //appropriate responses to silly attempts like "opening" a human being.
eDoor //similar to eHeavy but slightly more specific in regards to open/close/use
};
// START MODIFICATION
//import static void Unhandled(int door_script=0);
import static void Unhandled(eObjectType objType = eGizmo, int door_script=0); //I've put the new parameter first because you use it much more often
// END
// START MODIFICATION
//static void Verbs::Unhandled(int door_script)
static void Verbs::Unhandled(eObjectType objType, int door_script)
// END
{
bool moduleInitialized = false;
String defaultSentence_Pull ;
String defaultSentence_Push ;
String defaultSentence_Give ;
String defaultSentence_Interact ;
String defaultSentence_Look ;
String defaultSentence_PickUp ;
String defaultSentence_Talk ;
String defaultSentence_UseInv ;
String defaultSentence_Open ;
String defaultSentence_Close ;
function InitializeModule() {
//unfortunately AGS script does not allow to initialize a default
//String's value at declaration. We are forced to do it here
//universal sentences for any object in the entire game
defaultSentence_Pull = "I can't pull that.";
defaultSentence_Push = "I can't push that.";
defaultSentence_Give = "That just won't work.";
defaultSentence_Interact = "I don't know what to do.";
defaultSentence_Look = "I see nothing special about it.";
defaultSentence_PickUp = "Why would I want to pick that up?";
defaultSentence_Talk = "I shouldn't start talking to things.";
defaultSentence_UseInv = "That won't work.";
defaultSentence_Open = "I can't open that.";
defaultSentence_Close = "I can't close that.";
moduleInitialized = true; //make sure we don't call it again
}
//makes sure that all the relevant module stuff is initialized
function checkInitialized() {
//at first call
if (!moduleInitialized)
InitializeModule();
}
String FindWontWorkSentence() {
String wontWork[10];
wontWork[0] = "That won't work.";
wontWork[1] = "I don't think that will work.";
wontWork[2] = "Nu-uh.";
wontWork[3] = "No.";
wontWork[4] = "Nope.";
wontWork[5] = "That's silly.";
wontWork[6] = "Why would I try that?";
wontWork[7] = "I'll have to think of something more useful.";
wontWork[8] = "No way.";
wontWork[9] = "I can't figure it out.";
return wontWork[Random(9)];
}
String FindWontGiveSentence() {
String wontGive[4];
wontGive[0] = "I'd rather keep that to myself.";
wontGive[1] = "I won't give that away.";
wontGive[2] = "Bad idea.";
wontGive[3] = "Let's keep that to myself.";
return wontGive[Random(3)];
}
String Sentence(Action_7CoG mode, eObjectType objectType) {
checkInitialized();
String sentence = "ERROR : no sentence returned.";
if (objectType == eGizmo) { //See the definition of "eGizmo" in the Enum declaration
if (mode == eGA_7CoG_Pull) sentence = defaultSentence_Pull; //Pull
else if (mode == eGA_7CoG_Push) sentence = defaultSentence_Push; //Push
else if (mode == eGA_7CoG_GiveTo) sentence = FindWontGiveSentence(); // Give
else if (mode == eGA_7CoG_Use) sentence = FindWontWorkSentence(); // Interact
else if (mode == eGA_7CoG_LookAt) sentence = defaultSentence_Look; // Look
else if (mode == eGA_7CoG_PickUp) sentence = "I don't need that."; // Pickup
else if (mode == eGA_7CoG_TalkTo) sentence = defaultSentence_Talk; // Talk
else if (mode == eGA_7CoG_UseInv) sentence = FindWontWorkSentence(); // Useinv
else if (mode == eGA_7CoG_Open) sentence = defaultSentence_Open; // Useinv
else if (mode == eGA_7CoG_Close) sentence = defaultSentence_Close; // Useinv
else sentence = String.Format("Unknown mode : %d",mode);
} else if (objectType == eHeavy) { //See the definition of "eHeavy" in the Enum declaration
if (mode == eGA_7CoG_Pull) sentence = "It's too heavy to pull it"; //Pull
else if (mode == eGA_7CoG_Push) sentence = "It's too heavy to push it"; //Push
else if (mode == eGA_7CoG_GiveTo) sentence = FindWontGiveSentence(); // Give
else if (mode == eGA_7CoG_Use) sentence = "Let it be."; // Interact
else if (mode == eGA_7CoG_LookAt) sentence = defaultSentence_Look; // Look
else if (mode == eGA_7CoG_PickUp) sentence = "I can't pick up something that big!"; // Pickup
else if (mode == eGA_7CoG_TalkTo) sentence = defaultSentence_Talk; // Talk
else if (mode == eGA_7CoG_UseInv) sentence = defaultSentence_UseInv; // Useinv
else if (mode == eGA_7CoG_Open) sentence = defaultSentence_Open; // Useinv
else if (mode == eGA_7CoG_Close) sentence = defaultSentence_Close; // Useinv
else sentence = String.Format("Unknown mode : %d",mode);
} else if (objectType == eCharacter) { //See the definition of "eHeavy" in the Enum declaration
if (mode == eGA_7CoG_Pull) sentence = "Violence is not a solution here."; //Pull
else if (mode == eGA_7CoG_Push) sentence = "I don't just push people around."; //Push
else if (mode == eGA_7CoG_GiveTo) sentence = FindWontGiveSentence(); // Give
else if (mode == eGA_7CoG_Use) sentence = "I don't randomly touch people."; // Interact
else if (mode == eGA_7CoG_LookAt) sentence = defaultSentence_Look; // Look
else if (mode == eGA_7CoG_PickUp) sentence = "Yes, why don't I just carry everybody around on my back?"; // Pickup
else if (mode == eGA_7CoG_TalkTo) sentence = defaultSentence_Talk; // Talk
else if (mode == eGA_7CoG_UseInv) sentence = defaultSentence_UseInv; // Useinv
else if (mode == eGA_7CoG_Open) sentence = "You mean, open that person with a knife or something?"; // Useinv
else if (mode == eGA_7CoG_Close) sentence = "That doesn't make sense."; // Useinv
else sentence = String.Format("Unknown mode : %d",mode);
} else if (objectType == eDoor) { //See the definition of "eDoor" in the Enum declaration
if (mode == eGA_7CoG_Pull) sentence = "It's too heavy to pull it"; //Pull
else if (mode == eGA_7CoG_Push) sentence = "It's too heavy to push it"; //Push
else if (mode == eGA_7CoG_GiveTo) sentence = FindWontGiveSentence(); // Give
else if (mode == eGA_7CoG_Use) sentence = "Let it be."; // Interact
else if (mode == eGA_7CoG_LookAt) sentence = defaultSentence_Look; // Look
else if (mode == eGA_7CoG_PickUp) sentence = "I can't pick up something that big!"; // Pickup
else if (mode == eGA_7CoG_TalkTo) sentence = defaultSentence_Talk; // Talk
else if (mode == eGA_7CoG_UseInv) sentence = defaultSentence_UseInv; // Useinv
else if (mode == eGA_7CoG_Open) sentence = defaultSentence_Open; // Useinv
else if (mode == eGA_7CoG_Close) sentence = defaultSentence_Close; // Useinv
else sentence = String.Format("Unknown mode : %d",mode);
} else { //the most possible generic sentences
if (mode == eGA_7CoG_Pull) sentence = defaultSentence_Pull; //Pull
else if (mode == eGA_7CoG_Push) sentence = defaultSentence_Push; //Push
else if (mode == eGA_7CoG_GiveTo) sentence = FindWontGiveSentence(); // Give
else if (mode == eGA_7CoG_Use) sentence = defaultSentence_Interact; // Interact
else if (mode == eGA_7CoG_LookAt) sentence = defaultSentence_Look; // Look
else if (mode == eGA_7CoG_PickUp) sentence = FindWontWorkSentence(); // Pickup
else if (mode == eGA_7CoG_TalkTo) sentence = defaultSentence_Talk; // Talk
else if (mode == eGA_7CoG_UseInv) sentence = FindWontWorkSentence(); // Useinv
else if (mode == eGA_7CoG_Open) sentence = defaultSentence_Open; // Useinv
else if (mode == eGA_7CoG_Close) sentence = defaultSentence_Close; // Useinv
else sentence = String.Format("Unknown mode : %d",mode);
}
return sentence;
}
function dialog_options_mouse_click(DialogOptionsRenderingInfo *info, MouseButton button)
{
CDG_Arrow uparrow;
CDG_Arrow downarrow;
int i;
// Up-Arrow coordinates
uparrow.x1 = info.X + CDG_options.uparrow_xpos;
uparrow.y1 = info.Y + CDG_options.uparrow_ypos ;
uparrow.x2 = uparrow.x1 + Game.SpriteWidth[CDG_options.uparrow_img];
uparrow.y2 = uparrow.y1 + Game.SpriteHeight[CDG_options.uparrow_img];
// Down-Arrow coordinates
downarrow.x1 = info.X + CDG_options.downarrow_xpos;
downarrow.y1 = info.Y + CDG_options.downarrow_ypos ;
downarrow.x2 = downarrow.x1 + Game.SpriteWidth[CDG_options.downarrow_img];
downarrow.y2 = downarrow.y1 + Game.SpriteHeight[CDG_options.downarrow_img];
//MODIFIED BY SEVEN CITIES - START
bool isClickScrollUp = ((mouse.x >= uparrow.x1 && mouse.y >= uparrow.y1) &&
(mouse.x <= uparrow.x2 && mouse.y <= uparrow.y2))||
(button == eMouseWheelNorth && CDG_options.mousewheel);
bool isClickScrollDown = ((mouse.x >= downarrow.x1 && mouse.y >= downarrow.y1) &&
(mouse.x <= downarrow.x2 && mouse.y <= downarrow.y2)) ||
(button == eMouseWheelSouth && CDG_options.mousewheel);
//MODIFIED BY SEVEN CITIES - END
// scroll up
if (isClickScrollUp) {
i=0;
while (i<CDG_options.scroll_rows)
{
if (CDG_options.scroll_from >1) CDG_options.scroll_from --;
dialog_options_render(info);
i++;
}
}
// scroll down
else if (isClickScrollDown) {
i=0;
while (i<CDG_options.scroll_rows)
{
if (CDG_options.scroll_to != CDG_options.active_options_count-1) {
dialog_options_render(info);
CDG_options.scroll_from ++;
}
i++;
}
}
info.Update();
//MODIFIED BY SEVEN CITIES - START
//if (button != eMouseWheelSouth && button != eMouseWheelNorth) info.RunActiveOption();
if (!isClickScrollDown && !isClickScrollUp){
CDG_options.scroll_from = 0; // Scroll to top
info.Update();
info.RunActiveOption();
}
//MODIFIED BY SEVEN CITIES - END
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.110 seconds with 18 queries.