Hitting "code too large" error - ideas?
Monkey Targets Forums/Android/Hitting "code too large" error - ideas?
| ||
Hi all, I'm getting a "code too large" error when I try to compile my latest project for Android. Looks like I'm hitting on of Java's hard limits - variables can't take up more than 64K One culprit is an Int array which I use for storing level (layout) data. Basically, I have a monster array of Ints, which I then take subsets thereof for each level. Global olevel:Int[]=[ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,1,1,1, 1,1,13... etc. One idea I had for saving space would be to use a Char type instead, but I don't think we have that in Monkey. Maybe I could use a String type, and write some code to convert the data on the fly.. any other ideas? Cheers, Tom |
| ||
why don't use a textfile? |
| ||
does using 4 bits(nible) to store 8 nibles in each int work for you: [$11011111,$040900f1,.....] each digit represent a value from 0 to 15. |
| ||
something like this:Strict Function Main:Int() Local p:MyMap = New MyMap Print p.Get(1) Print p.Get(7) Print p.Get(8) Return 1 End Function Class MyMap Global area:Int[]= [$18141f1c,$41111111] Method Get:Int(n:Int) Return (area[n/8] Shr ((7-(n Mod 8))*4)) & $F End Method End class |
| ||
Thanks for the ideas, guys.. @Rone - didn't know I could use external text files with monkey.. How can I do that? |
| ||
@Rone - didn't know I could use external text files with monkey.. How can I do that? supposed to be a joke?? if not: 1. create a text file in project.data 2. copy/paste your data 3. local data:= LoadString("olevel.txt") And if possible, use a file per level. I think monkey now also supports binary files on all targets using BBDataBuffer.Load... |
| ||
No joke, genuinely didn't know / never needed to use that before..the only external files I've used before are for grafix and sound.. Thanks for your help :-) |
| ||
Or just split your monster. May be simplest if you are not far above the limit and you have code to output level designs in your current format. That said, using a better method will equip you for next time. |
| ||
Cheers, I'm going down the 1 file per level/ read in as needed at runtime route.. thanks, all for ideas |