Sscanf bug?
#1

This is my Table on DB:
[img width=1024 height=446]http://i.fhqhosting.com/screenbiz.bmp[/img]

This is my Script:

Код:
for(new i=0;i<MAX_BIZ;i++)
	{
		new STRINGAVALORI[1024];
		format(StringaQuery, sizeof(StringaQuery),"SELECT * FROM Biz WHERE bID = %d",i);
		EseguiQuery(StringaQuery);
		mysql_store_result();
		mysql_fetch_row_format(STRINGAVALORI,"|");
		printf("DEBUG [Load Biz Number %d]: %s",i,STRINGAVALORI);

		sscanf(STRINGAVALORI,"p|dddsdsddffffffdfffdfffdddddddddd",
		BizzInfo[i][bID],
		BizzInfo[i][bLevel],
		BizzInfo[i][bValue],
		BizzInfo[i][bDiscription],
		BizzInfo[i][bOwned],
		BizzInfo[i][bOwner],
		BizzInfo[i][bLock],
		BizzInfo[i][bInt],
		BizzInfo[i][bEntrancex],
		BizzInfo[i][bEntrancey],
		BizzInfo[i][bEntrancez],
		BizzInfo[i][bExitx],
		BizzInfo[i][bExity],
		BizzInfo[i][bExitz],
		BizzInfo[i][bHel],
		BizzInfo[i][bHealthx],
		BizzInfo[i][bHealthy],
		BizzInfo[i][bHealthz],
		BizzInfo[i][bArm],
		BizzInfo[i][bArmourx],
		BizzInfo[i][bArmoury],
		BizzInfo[i][bArmourz],
		BizzInfo[i][bEntcost],
		BizzInfo[i][bTakings],
		BizzInfo[i][bDate],
		BizzInfo[i][bProd],
		BizzInfo[i][bProdCap],
		BizzInfo[i][bComp],
		BizzInfo[i][bCompCap],
		BizzInfo[i][bProdCost],
		BizzInfo[i][bPayComp],
		BizzInfo[i][bPriceMod]);

		printf("BizzInfo[i][bID] = %d",BizzInfo[i][bID]);
		printf("BizzInfo[i][bLevel] = %d",BizzInfo[i][bLevel]);
		printf("BizzInfo[i][bValue] = %d",BizzInfo[i][bValue]);
		printf("BizzInfo[i][bDiscription] = %s",BizzInfo[i][bDiscription]);
		printf("BizzInfo[i][bOwned] = %d",BizzInfo[i][bOwned]);
		printf("BizzInfo[i][bOwner] = %s",BizzInfo[i][bOwner]);
		printf("BizzInfo[i][bLock] = %d",BizzInfo[i][bLock]);
		printf("BizzInfo[i][bInt] = %d",BizzInfo[i][bInt]);
		printf("BizzInfo[i][bEntrancex] = %2.f",BizzInfo[i][bEntrancex]);
		printf("BizzInfo[i][bEntrancey] = %2.f",BizzInfo[i][bEntrancey]);
		printf("BizzInfo[i][bEntrancez] = %2.f",BizzInfo[i][bEntrancey]);
		printf("BizzInfo[i][bExitx] = %2.f",BizzInfo[i][bExitx]);
		printf("BizzInfo[i][bExity] = %2.f",BizzInfo[i][bExity]);
		printf("BizzInfo[i][bExitz] = %2.f",BizzInfo[i][bExity]);
		printf("BizzInfo[i][bHel] = %d",BizzInfo[i][bHel]);
		printf("BizzInfo[i][bHealthx] = %2.f",BizzInfo[i][bHealthx]);
		printf("BizzInfo[i][bHealthy] = %2.f",BizzInfo[i][bHealthy]);
		printf("BizzInfo[i][bHealthz] = %2.f",BizzInfo[i][bHealthy]);
		printf("BizzInfo[i][bArm] = %d",BizzInfo[i][bArm]);
		printf("BizzInfo[i][bArmourx] = %2.f",BizzInfo[i][bArmourx]);
		printf("BizzInfo[i][bArmoury] = %2.f",BizzInfo[i][bArmoury]);
		printf("BizzInfo[i][bArmourz] = %2.f",BizzInfo[i][bArmourz]);
		printf("BizzInfo[i][bEntcost] = %d",BizzInfo[i][bEntcost]);
		printf("BizzInfo[i][bTakings] = %d",BizzInfo[i][bTakings]);
		printf("BizzInfo[i][bDate] = %d",BizzInfo[i][bDate]);
		printf("BizzInfo[i][bProd] = %d",BizzInfo[i][bProd]);
		printf("BizzInfo[i][bProdCap] = %d",BizzInfo[i][bProdCap]);
		printf("BizzInfo[i][bComp] = %d",BizzInfo[i][bComp]);
		printf("BizzInfo[i][bCompCap] = %d",BizzInfo[i][bCompCap]);
		printf("BizzInfo[i][bProdCost] = %d",BizzInfo[i][bProdCost]);
		printf("BizzInfo[i][bPayComp] = %d",BizzInfo[i][bPayComp]);
		printf("BizzInfo[i][bPriceMod] = %d",BizzInfo[i][bPriceMod]);
	}
This is my log:

[15:11:38] DEBUG [Load Biz Number 1]: 1|11|5000000|Donut Place|0|The State|1|17|1038.09|-1338.80|13.69|377.00|-192.39|1000.59|0|374.00|-184.00|1000.00|0|374.00|-184.00|1000.00|0|71400|276|-2274|500|0|10|5|10000|0
[15:11:38] BizzInfo[i][bID] = 1
[15:11:38] BizzInfo[i][bLevel] = 11
[15:11:38] BizzInfo[i][bValue] = 5000000
[15:11:38] BizzInfo[i][bDiscription] = Donut Place
[15:11:38] BizzInfo[i][bOwned] = 0
[15:11:38] BizzInfo[i][bOwner] = The State
[15:11:38] BizzInfo[i][bLock] = 1
[15:11:38] BizzInfo[i][bInt] = 17
[15:11:38] BizzInfo[i][bEntrancex] = 0
[15:11:38] BizzInfo[i][bEntrancey] = 0
[15:11:38] BizzInfo[i][bEntrancez] = 0
[15:11:38] BizzInfo[i][bExitx] = 0
[15:11:38] BizzInfo[i][bExity] = 0
[15:11:38] BizzInfo[i][bExitz] = 0

[15:11:38] BizzInfo[i][bHel] = 0
[15:11:38] BizzInfo[i][bHealthx] = 0
[15:11:38] BizzInfo[i][bHealthy] = 0
[15:11:38] BizzInfo[i][bHealthz] = 0
[15:11:38] BizzInfo[i][bArm] = 0
[15:11:38] BizzInfo[i][bArmourx] = 374
[15:11:38] BizzInfo[i][bArmoury] = -184
[15:11:38] BizzInfo[i][bArmourz] = 1000
[15:11:38] BizzInfo[i][bEntcost] = 0
[15:11:38] BizzInfo[i][bTakings] = 71400
[15:11:38] BizzInfo[i][bDate] = 276
[15:11:38] BizzInfo[i][bProd] = -2274
[15:11:38] BizzInfo[i][bProdCap] = 500
[15:11:38] BizzInfo[i][bComp] = 0
[15:11:38] BizzInfo[i][bCompCap] = 10
[15:11:38] BizzInfo[i][bProdCost] = 5
[15:11:38] BizzInfo[i][bPayComp] = 10000
[15:11:38] BizzInfo[i][bPriceMod] = 0
.....
..

It's a sscanf Bug?
Reply
#2

And how is your enum declared ?
Reply
#3

Код:
enum bInfo
{
	bID,
	bLevel,
	bValue,
	bDiscription[128],
	bOwned,
	bOwner[MAX_PLAYER_NAME],
	bLock,
	bInt,
	Float:bEntrancex,
	Float:bEntrancey,
	Float:bEntrancez,
	Float:bExitx,
	Float:bExity,
	Float:bExitz,
	bHel,
	Float:bHealthx,
	Float:bHealthy,
	Float:bHealthz,
	bArm,
	Float:bArmourx,
	Float:bArmoury,
	Float:bArmourz,
	bEntcost,
	bTakings,
	bDate,
	bProd,
	bProdCap,
	bComp,
	bCompCap,
	bProdCost,
	bPayComp,
	bPriceMod
};
Reply
#4

Sscanf's original code has a bug with floats. Replace case f with the next code (fix wasn't made by me btw).

pawn Код:
case 'f':
            {
              new changestr[16], changepos = 0, strpos = stringPos;
                while(changepos < 16 && string[strpos] && string[strpos] != delim)
                {
                changestr[changepos++] = string[strpos++];
              }
              changestr[changepos] = '\0';
              setarg(paramPos,0,_:floatstr(changestr));
            }
Reply
#5

Thanks $ЂЯĢ.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)