Since I've breached the 2mb mapscript size, I tried to find where the mapscript border is.
Rumors stated that it was at approximately 2mb of uncompressed script size.
I've made some tests in my Diablo map with the result that 3061kb of uncompressed "Mapscript.galaxy" file is still executed properly (at least offline via editor test).
Having much more kb results in an editor error message while compiling stating that the script is to long.
So either a patch changed it or people had a ton of variables more than me.
But I'm already using 3051 global variables (this value counts every variable slots possible within arrays, so this is the total amount of fields used as global variables).
I triggered everything with GUI.
The .galaxy file produced has 93.764 lines, contains 2.947.261 characters and has a compressed size of 189kb within the map.
I'm quite happy that I've still 1mb of script memory left to tinker with in my map.
Maybe DarkRevenant can continue his Mafia map as I have no idea why he hit it at 2mb when I'm hitting it at 3mb.
I thought I should share my recently gained knowledge.
Interesting development, but how did you come up with this? "I'm quite happy that I've still 1mb of script memory left to tinker with in my map."
I can't figure it out from the rest of your post, did you test up to 4mb too?
So I tested how much code I can copy in my map before it starts to throw errors or just won't load the triggers and I was able to run it with 3061kb.
-> I've still 1 mb left to fill with code.
But Kueken just told me that the data objects (units, etc...) count to the script limit, too.
This seems quite unfortunate. :(
But Kueken just told me that the data objects (units, etc...) count to the script limit, too.
This seems quite unfortunate. :(
I am not entirely sure; I just noticed in a map, where I was testing script limits, new data objects seemed to affect the limit. However, I only tested the variables limit with one huge array, so objects are probably unrelated to the size of the script file.
Since I've breached the 2mb mapscript size, I tried to find where the mapscript border is.
Rumors stated that it was at approximately 2mb of uncompressed script size.
I've made some tests in my Diablo map with the result that 3061kb of uncompressed "Mapscript.galaxy" file is still executed properly (at least offline via editor test).
Having much more kb results in an editor error message while compiling stating that the script is to long.
So either a patch changed it or people had a ton of variables more than me.
But I'm already using 3051 global variables (this value counts every variable slots possible within arrays, so this is the total amount of fields used as global variables).
I triggered everything with GUI.
The .galaxy file produced has 93.764 lines, contains 2.947.261 characters and has a compressed size of 189kb within the map.
I'm quite happy that I've still 1mb of script memory left to tinker with in my map.
Maybe DarkRevenant can continue his Mafia map as I have no idea why he hit it at 2mb when I'm hitting it at 3mb.
I thought I should share my recently gained knowledge.
It is all how you coded your map. If you code like crap and have a bunch of redundancy. You will reach the script limit. If you know how to filter the data and use "Create Thread" in its correct place.... Well it is almost impossible to reach scriptlimit...
How "create thread" is relevant here, if the sizes are dependant on the script line amount? refacturing and optimizing the code is the only way to beat the script size. Correct me if I'm mistacken.
The memory limits are 2 MiB script bytecode, 2 MiB global variables, 32KiB - 1 byte local variable memory, 5 MiB per script file. Script bytecode and variable memory limits include dependencies, while script file size is per file.
The only way to address hitting any of these memory limits is to script more efficiently, abstract out repeated code, and use variables responsibly.
A patch changed it recently to explicitly tell you when the script is too large (most of the time). Before this, you just discovered your map having no script at all when it loaded up (no error, usually). The size itself was not changed.The script limit depends on two separate things:
1. Runtime memory: This is breached by running too many things at once, having a ton of local variables, and such. You are much more likely to hit the operation limit than to his this limit, though.
2. Static memory: This is breached by having lots of instructions in your code and having lots of global variables. You can hit this at 100KB to 4MB of uncompressed galaxy script, depending on your variables.
Mafia has lots and lots of variables. I am pretty good about keeping the variable usage down, but there are only so many ways I can optimize it without being able to use pointers. In total, including array indices, it is too large to count manually, but I estimate Mafia has multiple 100,000s of global variables. It's that kind of game; there really is no way around it. (With pointers or objects I could probably pare that down to just a couple thousand if I rewrote the entire game)
And Jademus, I'm not so sure that global variables and script bytecode are separate limits. I have tested this; raising a variable's array size to something retarded caused the map to hit the script limit much earlier than normal.
I hadn't thought to test the script bytecode and global variable memory limits together, haha. I'll need to test that, unless you have a script on hand that would save me the trouble.
Since I've breached the 2mb mapscript size, I tried to find where the mapscript border is.
Rumors stated that it was at approximately 2mb of uncompressed script size.
I've made some tests in my Diablo map with the result that 3061kb of uncompressed "Mapscript.galaxy" file is still executed properly (at least offline via editor test).
Having much more kb results in an editor error message while compiling stating that the script is to long.
So either a patch changed it or people had a ton of variables more than me.
But I'm already using 3051 global variables (this value counts every variable slots possible within arrays, so this is the total amount of fields used as global variables).
I triggered everything with GUI.
The .galaxy file produced has 93.764 lines, contains 2.947.261 characters and has a compressed size of 189kb within the map.
I'm quite happy that I've still 1mb of script memory left to tinker with in my map.
Maybe DarkRevenant can continue his Mafia map as I have no idea why he hit it at 2mb when I'm hitting it at 3mb.
I thought I should share my recently gained knowledge.
@Ahli634: Go
Interesting development, but how did you come up with this? "I'm quite happy that I've still 1mb of script memory left to tinker with in my map." I can't figure it out from the rest of your post, did you test up to 4mb too?
@zorbotron: Go I'm at 2038kb in my map currently.
So I tested how much code I can copy in my map before it starts to throw errors or just won't load the triggers and I was able to run it with 3061kb.
-> I've still 1 mb left to fill with code.
But Kueken just told me that the data objects (units, etc...) count to the script limit, too.
This seems quite unfortunate. :(
I am not entirely sure; I just noticed in a map, where I was testing script limits, new data objects seemed to affect the limit. However, I only tested the variables limit with one huge array, so objects are probably unrelated to the size of the script file.
It is all how you coded your map. If you code like crap and have a bunch of redundancy. You will reach the script limit. If you know how to filter the data and use "Create Thread" in its correct place.... Well it is almost impossible to reach scriptlimit...
How "create thread" is relevant here, if the sizes are dependant on the script line amount? refacturing and optimizing the code is the only way to beat the script size. Correct me if I'm mistacken.
A patch changed it recently to explicitly tell you when the script is too large (most of the time). Before this, you just discovered your map having no script at all when it loaded up (no error, usually). The size itself was not changed.The script limit depends on two separate things:
1. Runtime memory: This is breached by running too many things at once, having a ton of local variables, and such. You are much more likely to hit the operation limit than to his this limit, though.
2. Static memory: This is breached by having lots of instructions in your code and having lots of global variables. You can hit this at 100KB to 4MB of uncompressed galaxy script, depending on your variables.
Mafia has lots and lots of variables. I am pretty good about keeping the variable usage down, but there are only so many ways I can optimize it without being able to use pointers. In total, including array indices, it is too large to count manually, but I estimate Mafia has multiple 100,000s of global variables. It's that kind of game; there really is no way around it. (With pointers or objects I could probably pare that down to just a couple thousand if I rewrote the entire game)
And Jademus, I'm not so sure that global variables and script bytecode are separate limits. I have tested this; raising a variable's array size to something retarded caused the map to hit the script limit much earlier than normal.
Here you go. Don't worry about the errors; just delete the stuff that points to outside libraries.
http://www.sc2mafia.com/junk/Stuff.7z