PDA

View Full Version : #include limits?



ZNorQ
Jan 2 2012, 17:25
Hey,

I'm a heavy user of #include, and there are files with #include statements on several levels.

Example;

init.sqf;
#include "file2.cpp"

file2.cpp;
#include "file3.cpp"

file3.cpp;
#include "file4"

Seems I've come to a point where it absolutely refuses to include more files (it wont execute the code.). Can anyone confirm this?

ZNorQ

AZCoder
Jan 2 2012, 18:25
Out of curiosity I did a quick test where I went 4 files deep and had each one send a message to the screen. Worked fine. Off the top of my head, make sure that none of those files are being included more than once, otherwise infinite recursion might break it. Also check the error log, it might provide a clue.

ZNorQ
Jan 2 2012, 20:39
I 100% sure it isn't a recursion problem. I do have pretty long folder-and file names, perhaps that's a problem.

I'll try shortening the folder/file names and see if that remedies the problem, and/or if there is a deeper than level 4 nesting.

Thanks for the feedback, AZCoder.

ZNorQ

PS! If you conduct further tests, I hope you share the results? :)

---------- Post added at 10:39 PM ---------- Previous post was at 10:32 PM ----------

Just verified that it's level three deep, and the total path to the last include counts to 140 chars..;

C:\Users\ZNorQ\Documents\ArmA 2\MPMissions\NSF4_Template.Desert_E\components\sqf\client\playerSetup\equipment\nsf_equipSpecOpsDemolition.sqi

init.sqf;
#include "components\sqf\client\nsf_doPlayerSetup.sqi"

nsf_doPlayerSetup.sqi;
#include "playerSetup\nsf_doPlayerSetup_equipment.sqi"

nsf_doPlayerSetup_equipment.sqi;
#include "nsf_equipSpecOpsDemolition.sqi"

ZNorQ

AZCoder
Jan 2 2012, 22:28
Doesn't that last one need to be


#include "equipment\nsf_equipSpecOpsDemolition.sqi"

?

ZNorQ
Jan 3 2012, 07:05
Yes, you are right, and it is just a spelling mistake in my post.. Too bad that wasn't the answer to the problem. Anyway, I think if I'm trying to include something the engine can't find, there will be CTD incident..?

I've done some renaming to shorten the file names too, all in vain.. :/

ZNorQ

ZNorQ
Jan 5 2012, 10:09
After LOOONG and tedious code tracing, it seems to me that the init.sqf must be executed within a certain timeframe, and that this might be the source of my problems - not the #include itself.

Reference is given to XENO's init start-up (Domination), where the init.sqf is very short, while a addEventHandler/"Killed" starts a more lengthy version of the init.sqf (called d_init.sqf). My guess is that he's run into the same problem I have..?

One particular incident that underline my conclusion is that within one script the code stopped after a couple of lines;


[STATEMENT_LINE1]
[STATEMENT_LINE2]
[STATEMENT_LINE3]
...
<hereon and after; no code will be executed>
I verified this by inserting a variable = true at the first line (and worked), but placing it 3 lines down it suddenly became "any"...

Can anyone verify my conclusion?

ZNorQ

.kju [PvPscene]
Jan 5 2012, 11:53
Nope cannot confirm. Never had issues with loads of stacked includes either.
Do you use loadingScreen to speed up the processing of the init.sqf (or/and elsewhere)?

Disable code blocks to trace it down to the actual issue.

ZNorQ
Jan 5 2012, 12:50
No, I don't - I'm not even familiar with "loadingScreen". I'll do a check-up on it.

.kju [PvPscene]
Jan 5 2012, 13:22
http://community.bistudio.com/wiki/startLoadingScreen

ZNorQ
Jan 5 2012, 21:02
I found the problem, and it was Squint that helped me... Not that squint reported any problems; there where no errors, but the funny thing was that the whole code was on one line!

After re-opening the file(s) in notepad++ (my preferred coding tool), I saw that for some strange reason these files where in "Macintosh" format, which only uses LF (and not CR+LF), and since all my code starts with comments - I guess you can figure out where this is going...

Thanks to CarlGustaffa for hinting me to use Squint (which didn't find the error, but still did... Oo )

Maybe a squint update that warns people of wrong file format could be implemented?

Thanks to you guys who contributed in my search for answers, appreciate it.

ZNorQ

CarlGustaffa
Jan 5 2012, 21:08
Happy to be of assistance :) Blame my inactivity on the forums atm on Bethesda Game Studios :p Oh well, Skyrim is calling...