Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 8db5645
Author: dpomier <[email protected]>
Date:   Fri Feb 19 15:33:19 2021 +0100

    make getInt parse only when necessary

commit 87f3638
Author: dpomier <[email protected]>
Date:   Fri Feb 19 15:29:26 2021 +0100

    avoid unspecified behavior of Std.parseInt
  • Loading branch information
dpomier committed Feb 22, 2021
1 parent 27f0acf commit dee9320
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 5 additions & 2 deletions com/smartfoxserver/v2/entities/data/SFSObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,16 @@ class SFSObject implements ISFSObject
var wrapper:SFSDataWrapper = cast dataHolder[key];
if(wrapper != null)
{
#if (js || flash)
return wrapper.data;
#else
var value:Dynamic = wrapper.data;
if(Std.is(value, Int))
{
return value;
}
value = Std.parseInt(value);
return value;
return Std.parseInt(""+value);
#end
}else{
return 0; //==0
}
Expand Down
8 changes: 6 additions & 2 deletions com/smartfoxserver/v2/requests/GenericMessageRequest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ class GenericMessageRequest extends BaseRequest

if(_message==null || _message.length==0)
errors.push("Buddy message is empty!");

var recipientId:Int = Std.parseInt(_recipient);

var recipientId:Int = switch Std.parseInt("" + _recipient) {
case null: 0;
case v: v;
}

if(recipientId<0)
errors.push("Recipient is not online or not in your buddy list");
}
Expand Down

0 comments on commit dee9320

Please sign in to comment.