Skip to content

Commit eb04134

Browse files
authored
Merge pull request #22 from omcho420/master
use of 'sizeof' argument
2 parents 1ab08f4 + 23c031e commit eb04134

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

a_npc.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ native printf(const format[], {Float,_}:...);
288288
/// </remarks>
289289
/// <remarks>The values for the placeholders follow in the exact same order as parameters in the call. For example, <b><c>"I am %i years old"</c></b> - the <b><c>%i</c></b> will be replaced with an Integer variable, which is the person's age.</remarks>
290290
/// <remarks>You may optionally put a number between the <b><c>%</c></b> and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the number of decimal places beeing shown of a float, you can add <b><c>.&lt;max number&gt;</c></b> between the <b><c>%</c></b> and the <b><c>f</c></b>. (example: <b><c>%.2f</c></b>)</remarks>
291-
native format(output[], len, const format[], {Float,_}:...);
291+
native format(output[], len = sizeof output, const format[], {Float,_}:...);
292292

293293
/// <summary>Sets a 'timer' to call a function after some time. Can be set to repeat.</summary>
294294
/// <param name="funcname">Name of the function to call as a string. This must be a public function (forwarded). A null string here will crash the server</param>
@@ -512,7 +512,7 @@ native IsPlayerInRangeOfPoint(playerid, Float:range, Float:X, Float:Y, Float:Z);
512512
/// <seealso name="GetPlayerVersion"/>
513513
/// <remarks>A player's name can be up to 24 characters long (as of <b>0.3d R2</b>) by using <a href="#SetPlayerName">SetPlayerName</a>. This is defined in <c>a_samp.inc</c> as <b><c>MAX_PLAYER_NAME</c></b>. However, the client can only join with a nickname between 3 and 20 characters, otherwise the connection will be rejected and the player has to quit to choose a valid name.</remarks>
514514
/// <returns>The length of the player's name. <b><c>0</c></b> if player specified doesn't exist.</returns>
515-
native GetPlayerName(playerid, name[], len);
515+
native GetPlayerName(playerid, name[], len = sizeof name);
516516

517517
/// <summary>Checks if a player is connected (if an ID is taken by a connected player).</summary>
518518
/// <param name="playerid">The ID of the player to check</param>

a_players.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ native GetPlayerState(playerid);
611611
/// <seealso name="OnPlayerDisconnect"/>
612612
/// <remarks>This function does not work when used in <a href="#OnPlayerDisconnect">OnPlayerDisconnect</a> because the player is already disconnected. It will return an invalid IP (<b><c>255.255.255.255</c></b>). Save players' IPs under <a href="#OnPlayerConnect">OnPlayerConnect</a> if they need to be used under <a href="#OnPlayerDisconnect">OnPlayerDisconnect</a>. </remarks>
613613
/// <returns><b><c>1</c></b> on success and <b><c>0</c></b> on failure.</returns>
614-
native GetPlayerIp(playerid, name[], len);
614+
native GetPlayerIp(playerid, ip[], len = sizeof ip);
615615

616616
/// <summary>Get the ping of a player. The ping measures the amount of time it takes for the server to 'ping' the client and for the client to send the message back.</summary>
617617
/// <param name="playerid">The ID of the player to get the ping of</param>
@@ -653,7 +653,7 @@ native GetPlayerKeys(playerid, &keys, &updown, &leftright);
653653
/// <seealso name="GetPlayerVersion"/>
654654
/// <remarks>A player's name can be up to 24 characters long (as of <b>0.3d R2</b>) by using <a href="#SetPlayerName">SetPlayerName</a>. This is defined in <c>a_samp.inc</c> as <b><c>MAX_PLAYER_NAME</c></b>. However, the client can only join with a nickname between 3 and 20 characters, otherwise the connection will be rejected and the player has to quit to choose a valid name.</remarks>
655655
/// <returns>The length of the player's name. <b><c>0</c></b> if player specified doesn't exist.</returns>
656-
native GetPlayerName(playerid, name[], len);
656+
native GetPlayerName(playerid, name[], len = sizeof name);
657657

658658
/// <summary>Sets the game time for a player. If a player's clock is enabled (<a href="#TogglePlayerClock">TogglePlayerClock</a>) the time displayed by it will update automatically.</summary>
659659
/// <param name="playerid">The ID of the player to set the game time of</param>
@@ -1545,7 +1545,7 @@ native SetPVarString(playerid, const varname[], const string_value[]);
15451545
/// <seealso name="DeletePVar"/>
15461546
/// <remarks>If length of string is zero (value not set), string_return text will not be updated or set to anything and will remain with old data, neccesying that you clear the variable to blank value if <a href="#GetPVarString">GetPVarString</a> returns <b><c>0</c></b> if that behavior is undesired </remarks>
15471547
/// <returns>The length of the string.</returns>
1548-
native GetPVarString(playerid, const varname[], string_return[], len);
1548+
native GetPVarString(playerid, const varname[], string_return[], len = sizeof string_return);
15491549

15501550
/// <summary>Set a float player variable's value.</summary>
15511551
/// <param name="playerid">The ID of the player whose player variable will be set</param>
@@ -1607,7 +1607,7 @@ native GetPVarsUpperIndex(playerid);
16071607
/// <seealso name="GetPVarInt"/>
16081608
/// <seealso name="GetPVarFloat"/>
16091609
/// <seealso name="GetPVarString"/>
1610-
native GetPVarNameAtIndex(playerid, index, ret_varname[], ret_len);
1610+
native GetPVarNameAtIndex(playerid, index, ret_varname[], ret_len = sizeof ret_varname);
16111611

16121612
/// <summary>Gets the type (integer, float or string) of a player variable.</summary>
16131613
/// <param name="playerid">The ID of the player whose player variable to get the type of</param>
@@ -1775,7 +1775,7 @@ native GetPlayerAnimationIndex(playerid); // return the index of any running app
17751775
/// <seealso name="GetPlayerAnimationIndex"/>
17761776
/// <remarks>This function was added in <b>SA-MP 0.3b</b> and will not work in earlier versions!</remarks>
17771777
/// <returns><b><c>1</c></b> on success, <b><c>0</c></b> on failure.</returns>
1778-
native GetAnimationName(index, animlib[], len1, animname[], len2); // get the animation lib/name for the index
1778+
native GetAnimationName(index, animlib[], len1 = sizeof animlib, animname[], len2 = sizeof animname); // get the animation lib/name for the index
17791779

17801780
/// <summary>Retrieves a player's current <a href="http://wiki.sa-mp.com/wiki/SpecialActions">special action</a>.</summary>
17811781
/// <param name="playerid">The ID of the player to get the <a href="http://wiki.sa-mp.com/wiki/SpecialActions">special action</a> of</param>

a_samp.inc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ native printf(const format[], {Float,_}:...);
385385
/// </remarks>
386386
/// <remarks>The values for the placeholders follow in the exact same order as parameters in the call. For example, <b><c>"I am %i years old"</c></b> - the <b><c>%i</c></b> will be replaced with an Integer variable, which is the person's age.</remarks>
387387
/// <remarks>You may optionally put a number between the <b><c>%</c></b> and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces. To cut the number of decimal places beeing shown of a float, you can add <b><c>.&lt;max number&gt;</c></b> between the <b><c>%</c></b> and the <b><c>f</c></b>. (example: <b><c>%.2f</c></b>)</remarks>
388-
native format(output[], len, const format[], {Float,_}:...);
388+
native format(output[], len = sizeof output, const format[], {Float,_}:...);
389389

390390
/// <summary>This function sends a message to a specific player with a chosen color in the chat. The whole line in the chatbox will be in the set color unless color embedding is used (since <b><c>0.3c</c></b>).</summary>
391391
/// <param name="playerid">The ID of the player to display the message to</param>
@@ -653,7 +653,7 @@ native GetActorPoolSize();
653653
/// <remarks>This function was added in <b>SA-MP 0.3.7-R1</b> and will not work in earlier versions!</remarks>
654654
/// <remarks>The salt is appended to the end of the password, meaning password 'foo' and salt 'bar' would form 'foobar'. </remarks>
655655
/// <remarks>The salt should be random, unique for each player and at least as long as the hashed password. It is to be stored alongside the actual hash in the player's account. </remarks>
656-
native SHA256_PassHash(const password[], const salt[], ret_hash[], ret_hash_len); // SHA256 for password hashing
656+
native SHA256_PassHash(const password[], const salt[], ret_hash[], ret_hash_len = sizeof ret_hash_len); // SHA256 for password hashing
657657

658658
// Server wide persistent variable system (SVars)
659659

@@ -713,7 +713,7 @@ native SetSVarString(const varname[], const string_value[]);
713713
/// <seealso name="DeleteSVar"/>
714714
/// <remarks>This function was added in <b>SA-MP 0.3.7 R2</b> and will not work in earlier versions!</remarks>
715715
/// <returns>The length of the string.</returns>
716-
native GetSVarString(const varname[], string_return[], len);
716+
native GetSVarString(const varname[], string_return[], len = sizeof string_return);
717717

718718
/// <summary>Set a float server variable.</summary>
719719
/// <param name="varname">The name of the server variable</param>
@@ -772,7 +772,7 @@ native GetSVarsUpperIndex();
772772
/// <seealso name="GetSVarInt"/>
773773
/// <seealso name="GetSVarFloat"/>
774774
/// <seealso name="GetSVarString"/>
775-
native GetSVarNameAtIndex(index, ret_varname[], ret_len);
775+
native GetSVarNameAtIndex(index, ret_varname[], ret_len = sizeof ret_varname);
776776

777777
/// <summary>Gets the type (integer, float or string) of a server variable.</summary>
778778
/// <param name="varname">The name of the server variable to get the type of</param>
@@ -1020,7 +1020,7 @@ native SetWorldTime(hour);
10201020
/// <b><c>1</c></b>: The function executed successfully.<p/>
10211021
/// <b><c>0</c></b>: The function failed to execute. The weapon specified does not exist.
10221022
/// </returns>
1023-
native GetWeaponName(weaponid, weapon[], len);
1023+
native GetWeaponName(weaponid, weapon[], len = sizeof weapon);
10241024

10251025
/// <param name="enable"><b><c>1</c></b> to enable, <b><c>0</c></b> to disable tire popping</param>
10261026
/// <remarks>This function was removed in <b>SA-MP 0.3</b>. Tire popping is enabled by default. If you want to disable tire popping, you'll have to manually script it using <a href="#OnVehicleDamageStatusUpdate">OnVehicleDamageStatusUpdate</a>.</remarks>
@@ -1158,8 +1158,8 @@ native IsPlayerNPC(playerid);
11581158
native AddCharModel(baseid, newid, const dffname[], const txdname[]);
11591159
native AddSimpleModel(virtualworld, baseid, newid, const dffname[], const txdname[]);
11601160
native AddSimpleModelTimed(virtualworld, baseid, newid, const dffname[], const txdname[], timeon, timeoff);
1161-
native FindModelFileNameFromCRC(crc, retstr[], retstr_size);
1162-
native FindTextureFileNameFromCRC(crc, retstr[], retstr_size);
1161+
native FindModelFileNameFromCRC(crc, retstr[], retstr_size = sizeof retstr);
1162+
native FindTextureFileNameFromCRC(crc, retstr[], retstr_size = sizeof retstr);
11631163
native RedirectDownload(playerid, const url[]);
11641164

11651165
// Admin
@@ -1223,7 +1223,7 @@ native SendRconCommand(const command[]);
12231223
/// <seealso name="NetStats_GetIpPort"/>
12241224
/// <remarks>This function was added in <b>SA-MP 0.3c R4</b> and will not work in earlier versions!</remarks>
12251225
/// <remarks>This function may not return accurate data when used under <a href="#OnPlayerDisconnect">OnPlayerDisconnect</a> if the player has quit normally. It usually returns accurate data if the player has been kicked or has timed out.</remarks>
1226-
native GetPlayerNetworkStats(playerid, retstr[], retstr_size);
1226+
native GetPlayerNetworkStats(playerid, retstr[], retstr_size = sizeof retstr);
12271227

12281228
/// <summary>Gets the server's network stats and stores them in a string.</summary>
12291229
/// <param name="retstr">The string to store the network stats in, passed by reference</param>
@@ -1262,7 +1262,7 @@ native GetPlayerNetworkStats(playerid, retstr[], retstr_size);
12621262
/// </c>
12631263
/// </remarks>
12641264
/// <returns>This function always returns <b><c>1</c></b>.</returns>
1265-
native GetNetworkStats(retstr[], retstr_size);
1265+
native GetNetworkStats(retstr[], retstr_size = sizeof retstr);
12661266

12671267
/// <summary>Returns the SA-MP client version, as reported by the player.</summary>
12681268
/// <param name="playerid">The ID of the player to get the client version of</param>
@@ -1274,7 +1274,7 @@ native GetNetworkStats(retstr[], retstr_size);
12741274
/// <remarks>This function was added in <b>SA-MP 0.3e</b> and will not work in earlier versions!</remarks>
12751275
/// <remarks>The string the version gets stored in will be empty if playerid is an NPC.</remarks>
12761276
/// <returns><b><c>1</c></b> on success and <b><c>0</c></b> on failure (if player specified doesn't exist).</returns>
1277-
native GetPlayerVersion(playerid, version[], len); // Returns the SA-MP client revision as reported by the player
1277+
native GetPlayerVersion(playerid, version[], len = sizeof version); // Returns the SA-MP client revision as reported by the player
12781278

12791279
/// <summary>Blocks an IP address from further communication with the server for a set amount of time (with wildcards allowed). Players trying to connect to the server with a blocked IP address will receive the generic "You are banned from this server." message. Players that are online on the specified IP before the block will timeout after a few seconds and, upon reconnect, will receive the same message.</summary>
12801280
/// <param name="ip_address">The IP to block</param>
@@ -1306,7 +1306,7 @@ native UnBlockIpAddress(const ip_address[]);
13061306
/// <remarks>Type 'varlist' in the server console to display a list of available server variables and their types.</remarks>
13071307
/// <remarks>When filterscripts or plugins is specified as the varname, this function only returns the name of the first specified filterscript or plugin. This is a bug.</remarks>
13081308
/// <returns>The length of the returned string. <b><c>0</c></b> if the specified server variable is not a string or doesn't exist.</returns>
1309-
native GetServerVarAsString(const varname[], buffer[], len);
1309+
native GetServerVarAsString(const varname[], buffer[], len = sizeof buffer);
13101310

13111311
/// <summary>Get the integer value of a server variable.</summary>
13121312
/// <param name="varname">The name of the integer variable to get the value of</param>
@@ -1337,7 +1337,7 @@ native GetServerVarAsBool(const varname[]);
13371337
/// <remarks>When filterscripts or plugins are specified as the varname, this function only returns the name of the first specified filterscript or plugin.</remarks>
13381338
/// <remarks>Using this function with anything other than a <b>string</b> (integer, boolean or float) will cause your server to crash. Using it with a nonexistent console variable will also cause your server to crash.</remarks>
13391339
/// <returns>The length of the returned string. <b><c>0</c></b> if the specified console variable is not a string or doesn't exist.</returns>
1340-
native GetConsoleVarAsString(const varname[], buffer[], len);
1340+
native GetConsoleVarAsString(const varname[], buffer[], len = sizeof buffer);
13411341

13421342
/// <summary>Get the integer value of a console variable.</summary>
13431343
/// <param name="varname">The name of the integer variable to get the value of</param>
@@ -1528,7 +1528,7 @@ native NetStats_ConnectionStatus(playerid);
15281528
/// <seealso name="NetStats_PacketLossPercent"/>
15291529
/// <seealso name="NetStats_ConnectionStatus"/>
15301530
/// <remarks>This function was added in <b>SA-MP 0.3z</b> and will not work in earlier versions!</remarks>
1531-
native NetStats_GetIpPort(playerid, ip_port[], ip_port_len);
1531+
native NetStats_GetIpPort(playerid, ip_port[], ip_port_len = sizeof ip_port);
15321532

15331533
// Menu
15341534

a_sampdb.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ native db_num_fields(DBResult:dbresult);
7070
/// <param name="maxlength">The max length of the field</param>
7171
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
7272
/// <returns>Returns <b><c>1</c></b>, if the function was successful, otherwise <b><c>0</c></b> if <b><c>DBResult:dbresult</c></b> is a <b><c>NULL</c></b> reference or the column index not available.</returns>
73-
native db_field_name(DBResult:dbresult, field, result[], maxlength);
73+
native db_field_name(DBResult:dbresult, field, result[], maxlength = sizeof result);
7474

7575
/// <summary>Get the content of a field from <a href="#db_query">db_query</a>.</summary>
7676
/// <param name="dbresult">The result to get the data from</param>
@@ -79,7 +79,7 @@ native db_field_name(DBResult:dbresult, field, result[], maxlength);
7979
/// <param name="maxlength">The max length of the field</param>
8080
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
8181
/// <returns>Returns <b><c>1</c></b> if successful, otherwise <b><c>0</c></b> if <b><c>DBResult:dbresult</c></b> is a <b><c>NULL</c></b> reference or the column index not available.</returns>
82-
native db_get_field(DBResult:dbresult, field, result[], maxlength);
82+
native db_get_field(DBResult:dbresult, field, result[], maxlength = sizeof result);
8383

8484
/// <summary>Get the content of a field as an integer from <a href="#db_query">db_query</a>.</summary>
8585
/// <param name="result">The result to get the data from</param>
@@ -102,7 +102,7 @@ native Float:db_get_field_float(DBResult:result, field = 0);
102102
/// <param name="maxlength">The max length of the field</param>
103103
/// <remarks>Using an <b>invalid handle</b> will crash your server! Get a <b>valid handle</b> by using <a href="#db_open">db_open</a>. But it's protected against <b><c>NULL</c></b> references</remarks>
104104
/// <returns>Returns <b><c>1</c></b> if successful, otherwise <b><c>0</c></b> if <b><c>DBResult:dbresult</c></b> is a <b><c>NULL</c></b> reference or the column index not available.</returns>
105-
native db_get_field_assoc(DBResult:dbresult, const field[], result[], maxlength);
105+
native db_get_field_assoc(DBResult:dbresult, const field[], result[], maxlength = sizeof result);
106106

107107
/// <summary>Get the contents of field as an integer with specified name.</summary>
108108
/// <param name="result">The result to get the data from</param>

0 commit comments

Comments
 (0)