sscanf issue - weird arrays?
#1

After searching the web for about an hour trying to find a solution to this, I find no other option but to consult the forums.

Here is my sscanf line:
pawn Код:
sscanf(line, "p<|>e<dddfffffffffffffdddddddd>", Door[i]);
My enum:
pawn Код:
enum DoorStatistics{
dID,
dType,
dLock,
Float:dX,
Float:dY,
Float:dZ,
Float:dRotX,
Float:dRotY,
Float:dRotZ,
Float:dXX,
Float:dYY,
Float:dZZ,
Float:dRotXX,
Float:dRotYY,
Float:dRotZZ,
Float:dSpeed,
dIcon,
dIconn,
dVW,
dInt,
dVWW,
dIntt,
dJob,
dOpen,

dExists,
dObject,
dObjectt,
dState,
};
new Door[MAX_DOORS][DoorStatistics];
This is what line[] inputs into the sscanf function after fetching it from the MySQL database:
Код:
1|1|0|661.2|-1531.41|14.58|0|0|0|661.2|-1531.31|14.58|0|0|90|0.05|1507|1507|0|0|0|0|0|1
And here, seperated by spaces, are the enums from dID to dOpen, after the sscanf function has been called:
Код:
1 1 0 -./,),(-*,(.(((((( 661.200012 -1531.410034 14.579999 0.000000 0.000000 0.000000 661.200012 -1531.310058 14.579999 0.000000 0.000000 90.000000 1507 1507 0 0 0 0 0 1
As you can see here, the float value 0.05 is being lost as a result of the other floats being pushed down the line.

In case you need that as well, here is the MySQL row exported:
Код:
INSERT INTO `doors` (`dID`, `dType`, `dLock`, `dX`, `dY`, `dZ`, `dRotX`, `dRotY`, `dRotZ`, `dXX`, `dYY`, `dZZ`, `dRotXX`, `dRotYY`, `dRotZZ`, `dSpeed`, `dIcon`, `dIconn`, `dVW`, `dInt`, `dVWW`, `dIntt`, `dJob`, `dOpen`) VALUES
(1, 1, 0, '661.2', '-1531.41', '14.58', '0', '0', '0', '661.2', '-1531.31', '14.58', '0', '0', '90', '0.05', 1507, 1507, 0, 0, 0, 0, 0, 1);
My problem here, as you can probably see, is that the 4th value is being stated as "-./,),(-*,(.((((((" in the output. It gets stored as a float, and pushes everything further down the line.

Does anyone know what is happening here, and how it may be fixed?


EDIT:
It seems to work just fine when I don't use the enum.
pawn Код:
sscanf(line, "p<|>dddfffffffffffffdddddddd", Door[i][dID], Door[i][dType], Door[i][dLock], Door[i][dX], Door[i][dY], Door[i][dZ], Door[i][dRotX], Door[i][dRotY],
Door[i][dRotZ], Door[i][dXX], Door[i][dYY], Door[i][dZZ], Door[i][dRotXX], Door[i][dRotYY], Door[i][dRotZZ], Door[i][dSpeed], Door[i][dIcon], Door[i][dIconn], Door[i][dVW], Door[i][dInt], Door[i][dVWW], Door[i][dIntt], Door[i][dJob], Door[i][dOpen]);
Output:
Код:
1 1 0 661.200012 -1531.410034 14.579999 0.000000 0.000000 0.000000 661.200012 -1531.310058 14.579999 0.000000 0.000000 90.000000 0.050000 1507 1507 0 0 0 0 0 1
Meaning the issue has to have something to do with the enum parameter, but what and how?
Reply
#2

Yes, OS is Debian x64, latest version.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)