Include directive bug
#1

Platform(s): Windows 7 (32bit and 64bit).
Server/Client Server.
Tested by Kyoshiro and Aleco.


I discovered a very odd bug with the include directive that basically stops code from being included into other scripts. The conditions are a bit weird, and i have no definite answers on what the cause may be, all i can do is just spell out the conditions. I had a friend test this bug with me and it seems that im not the only one, its not including code for him as well.

Basically i had a folder named DM inside the scriptfiles folder, and inside my DM folder was a folder name Scripts. Inside this Scripts folder there were a number of include files that my server used. The problem is, once i included more than 1 script the include process just completely broke. It would ONLY include the FIRST file, and never anything else. I declared variables in the other scripts that do not get used at all to see if i would get a warning message saying "variable blahblah isnt used", but i got nothing at all. This just pretty much proved it wasn't getting included, but i also went ahead and added two functions that print() the file name, and they also failed to be included/to work.

The weird thing is, im not getting an fatal warnings, the script is reading the files just fine! I tried MULTIPLE ways to include these files, and none of them worked.

my first try that failed was (Note there was more than one include, im shortening it):

Code:
#include "../scriptfiles/DM/Scripts/a_Master.txt"
then after a bit of failed testing i tried:

Code:
#include <../../scriptfiles/DM/Scripts/a_Master.txt>
Both of these method behaved exactly the same, ONE file was included (the first) and the rest were practically ignored. It wasn't until i moved my DM folder into the pawno/include folder that it actually worked (a friend also says that JUST the scriptfiles/DM/ worked for him. He said it stopped including code when he added another folder in the picture). Im thinking the issue is with long file paths (even though the above is pretty short-40 chars) or an issue related to folders. Im not really sure, and could use more testing to be honest (not sure if this is a pawn issue, or just a sa-mp issue either).

Its a pretty odd issue, and even though its not a common one, i think it should still be fixed (if possible) :P.
Reply
#2

Add those lines at the end of the script and compile again. By the way, why are you trying to add a .txt file to a pawn file?
Reply
#3

Quote:
Originally Posted by Y_Less
View Post
I assume you're compiling on Windows so have you tried using backslashes? pawncc doesn't overly like non-native separators.
This actually fixed the issue, it was my impression that either of them worked, i never knew pawncc didnt like the forward slashes! Whats weird to me is that the forward slash DOES work, it just stopped working when another folder came into the picture xD (like i said, ../scriptfiles/DM worked fine, wasnt until Scripts that it started failing).

My bad . Thanks for you post Y_Less.


Since pawncc obviously doesnt like this, i think grandlarc should be modded (as to not let people learn to use forward slashes/hit my mistake).

Code:
//from grandlarc.pwn
#include "../include/gl_common.inc"
#include "../include/gl_spawns.inc"
Quote:
Originally Posted by Miguel
View Post
Add those lines at the end of the script and compile again. By the way, why are you trying to add a .txt file to a pawn file?
The issue is fixed, but figured i shoud answer this as well. WHEN it was broken, location of the include didnt matter one bit, it still wouldnt include code. Moving it to the bottom would just mean more work (forwarding etc). Im including a text file because there i code inside it i want, duh :P! I could very well make it an actual include, but those open with the c++ IDE, and that takes to long, so i prefer txt.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)