sumoFFS - String error (sscanf2)
#1

Hello guys! I have this script and i want to update the sscanf plugin

pawn Код:
if(strcmp(line, "O", false, 1) == 0){
                if (!sscanf(line, "s[24]dffffff", letter, model, X, Y, Z, rX, rY, rZ)){
                    mapObjects[mapObjectsCounter] = CreateObject(model, X, Y, Z, rX, rY, rZ);
                    mapObjectsCounter++;
                } else {
                    printf("***** Invalid line for O at '%s' - %s", mapname, line);
                }
            }

In console i get that error msg Invalid line for O ....
Reply
#2

Have you tried:
pawn Код:
if(strcmp(line, "O", false, 1) == 0)
{                
    if(sscanf(line, "s[24]dffffff", letter, model, X, Y, Z, rX, rY, rZ)) return printf("***** Invalid line for O at '%s' - %s", mapname, line);
    mapObjects[mapObjectsCounter] = CreateObject(model, X, Y, Z, rX, rY, rZ);
    mapObjectsCounter++;
}
Reply
#3

I have this too...
pawn Код:
if(strcmp(line, "A", false, 1) == 0){
                sscanf(line, "ss", letter, mapAuthor);
            }

            if(strcmp(line, "V", false, 1) == 0){
                sscanf(line, "ss", letter, mapVersion);
            }

            if(strcmp(line, "N", false, 1) == 0){
                sscanf(line, "ss", letter, mapName);
            }

            if(strcmp(line, "T", false, 1) == 0){
                sscanf(line, "sd", letter, mapTreshold);
            }
           
            if(strcmp(line, "W", false, 1) == 0){
                sscanf(line, "sd", letter, mapWintime);
            }

            if(strcmp(line, "C", false, 1) == 0){
                if (!sscanf(line, "sfff", letter, X, Y, Z)){
                    mapCamera[COORD_X] = X;
                    mapCamera[COORD_Y] = Y;
                    mapCamera[COORD_Z] = Z;
                } else {
                    printf("***** Invalid line for C at '%s' - %s", mapname, line);
                }
            }
           
            if(strcmp(line, "L", false, 1) == 0){
                if (!sscanf(line, "sfff", letter, X, Y, Z)){
                    mapCameraLookAt[COORD_X] = X;
                    mapCameraLookAt[COORD_Y] = Y;
                    mapCameraLookAt[COORD_Z] = Z;
                } else {
                    printf("***** Invalid line for C at '%s' - %s", mapname, line);
                }
            }
Reply
#4

pawn Код:
if(strcmp(line, "C", false, 1) == 0)
{                
    if(sscanf(line, "sfff", letter, X, Y, Z)) return printf("***** Invalid line for C at '%s' - %s", mapname, line);
    {                    
        mapCamera[COORD_X] = X;                    
        mapCamera[COORD_Y] = Y;                    
        mapCamera[COORD_Z] = Z;                
    }
}
if(strcmp(line, "L", false, 1) == 0)
{                
    if(sscanf(line, "sfff", letter, X, Y, Z)) return printf("***** Invalid line for C at '%s' - %s", mapname, line);
    {                    
        mapCameraLookAt[COORD_X] = X;                    
        mapCameraLookAt[COORD_Y] = Y;                    
        mapCameraLookAt[COORD_Z] = Z;                
    }
}
Reply
#5

pawn Код:
[15:21:58]   Loaded.
[15:21:58]  Loaded 1 plugins.

[15:21:58]
[15:21:58] Filterscripts
[15:21:58] ---------------
[15:21:58]   Loaded 0 filterscripts.

[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for O at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for O at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for O at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for O at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for O at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ***** Invalid line for C at 'oasis' -
[15:21:58] ***** Invalid line for O at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ***** Invalid line for O at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] ***** Invalid line for S at 'oasis' -
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] sscanf warning: Strings without a length are deprecated, please add a destination size.
[15:21:58] ----------------------------------
[15:21:58]  sumoFFS v1.0 loaded
[15:21:58] ----------------------------------
Reply
#6

Hmmm, not too much experience with this, but try replacing:
Код:
"sfff"
with:
Код:
"s[1]fff"
Reply
#7

I will get
pawn Код:
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
[15:27:41] sscanf warning: String buffer overflow.
Reply
#8

Quote From ******' SSCANF Thread:
Quote:

This error comes up when people try and put too much data in to a string. For example:


pawn Код:
new str[10];sscanf("Hello there, how are you?", "s[10]", str);
That code will try and put the string "Hello there, how are you?" in to the variable called "str". However, "str" is only 10 cells big and can thus only hold the string "Hello ther" (with a NULL terminator). In this case, the rest of the data is ignored - which could be good or bad:


pawn Код:
new str[10], num;sscanf("Hello there you|42", "p<|>s[10]i", str, num);
In this case "num" is still correctly set to "42", but the warning is given for lost data ("e you").

Currently there is nothing you can do about this from a programming side (you can't even detect it - that is a problem I intend to address), as long as you specify how much data a user should enter this will simply discard the excess, or make the destination variable large enough to handle all cases.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)