Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistency overhaul #34

Open
wants to merge 106 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
d1ae325
Consistency improvements:
Y-Less Apr 27, 2021
c151017
Revert callback name changes because the compiler is picky about them.
Y-Less Apr 27, 2021
8bad002
More `camelCase` parameter names.
Y-Less Apr 27, 2021
78ef1ca
`id` -> `ID`
Y-Less Apr 27, 2021
35e40a9
Revert forwards again.
Y-Less Apr 27, 2021
c37b66d
`ID` is bad...
Y-Less Apr 27, 2021
e3584e1
More tweaks:
Y-Less Apr 27, 2021
6ec7e5f
Idiomatic DB function naming.
Y-Less Apr 27, 2021
a41db32
Name tweaks.
Y-Less May 4, 2021
04ca6ac
Fix clobbered names.
Y-Less May 4, 2021
2fa5a19
Another tag and name clobber.
Y-Less May 4, 2021
c5b0181
More tags.
Y-Less Oct 3, 2018
5e45fae
More enums.
Y-Less May 8, 2021
a14dace
Lost a load of commits due to repo corruption:
May 9, 2021
fc55463
More correct tag syntax.
May 9, 2021
1c03741
Callback tags.
May 9, 2021
3704e48
Document progressive tag enhancement.
May 9, 2021
cf78bdb
List of all updated callbacks.
May 9, 2021
1d46eb2
`KEY:`.
Y-Less May 11, 2021
e075fb1
Internal enum names.
Y-Less Aug 31, 2021
367be13
Internal enum names.
Y-Less Aug 31, 2021
54eadde
Internal enum names.
Y-Less Aug 31, 2021
32f9805
Internal enum names.
Y-Less Aug 31, 2021
8bd490d
Internal enum names.
Y-Less Aug 31, 2021
7dc15f4
Internal enum names.
Y-Less Aug 31, 2021
5ad1825
Fix a typo in `__SPECTATE_MODE` name.
Y-Less Dec 4, 2021
e13694a
More robust file inclusion/lookup.
Dec 4, 2021
72a0bbd
More definitions.
Dec 4, 2021
6b39b0b
`INVALID_TIMER`.
Dec 4, 2021
1f9f768
Integrate recent PRs.
Dec 4, 2021
6fd3ac2
typo fix: MAX_PLAYER_NAME minimum number.
Dec 18, 2021
51c9d9a
Merge pull request #41 from Kirima2nd/consistency-overhaul
Southclaws Dec 18, 2021
1fcfac3
Sync some defines with a_npc.
Jan 25, 2022
26ebabf
`WEAPON:` tag and `WEAPON_SPLAT` (based on the returned string).
Jan 25, 2022
29fa6fa
Two small camel case fixes.
Jan 29, 2022
b9aa7e9
More parameter renames, and `GPCI`.
Jan 29, 2022
5ebff26
Missing tags.
Jan 29, 2022
2a73ac8
`GetPlayerVehicleid` -> `GetPlayerVehicleID`.
Jan 30, 2022
171bb78
Remove `lenof`.
Jan 31, 2022
f1667df
Spacing fix.
Jan 31, 2022
ebea75e
Rename `CAMERA:` to `CAM_MOVE:` and add `CAM_MODE:`, for less clashy …
Jan 31, 2022
6ffb6a8
Fonts and `centre`.
Jan 31, 2022
7e89741
TD fonts.
Jan 31, 2022
9e17152
`forceSync` isn't a boolean.
Feb 2, 2022
643f3bb
Move readme sections to make more sense.
Y-Less Feb 2, 2022
7927f63
Variable name fix.
Feb 5, 2022
f9d22ce
Fix the pawndoc bug on `print`/`printf`.
Feb 22, 2022
9f1f59f
Switch pawndoc style.
Feb 26, 2022
10fe067
`<library>` header.
Feb 26, 2022
f95bc67
Fix some comment closes.
Feb 26, 2022
994f48c
Fix some comment closes.
Feb 26, 2022
048515f
Add `<library>` identifier to all natives.
Feb 26, 2022
c9a3180
Add `<library>` to some functions without other documentation.
Feb 26, 2022
e9b8955
Fix some inclusions.
Feb 26, 2022
2c1593a
Old-style include guards as well.
Feb 26, 2022
d2b4ee3
You'll prise two space full stops from my cold dead hands!
Feb 26, 2022
af6b7d6
Wrap pawndoc.
Feb 26, 2022
fd0663d
Wrap lines more aggressively.
Feb 26, 2022
054510b
Make the library declaration conditional.
Feb 26, 2022
475a955
Set library on constants.
Feb 27, 2022
1e5a62d
Better constants.
Feb 27, 2022
85b2063
enum documentation
Feb 27, 2022
89e8cf7
Return the correct enum names.
Feb 27, 2022
c885739
Trying to fix the bug.
Feb 27, 2022
3afdb09
Fix pawndoc bugs.
Feb 27, 2022
72c76dd
Add `///` before all enum documentation.
Feb 27, 2022
9c14138
Add `pawndoc.xsl`.
Feb 27, 2022
01a9527
Fix close tag.
Feb 27, 2022
3bcd294
`description=` to `summary=`
Feb 28, 2022
ab9c69e
Switch back to real defines so `#MAX_PLAYERS` etc work correctly. So…
Mar 6, 2022
873c512
Re-enable deprecation warnings.
Mar 6, 2022
bde8012
Fix replacement loop.
Mar 6, 2022
f98c14a
Hide some pawndoc better.
Mar 6, 2022
c8ad7a5
Two missing `a_npc` library tags.
Mar 6, 2022
c335579
Move some player defines around.
Mar 6, 2022
2295182
Separate header comments.
Mar 6, 2022
b0f9fe7
Move some defines to more appropriate files:
Mar 6, 2022
5b3d3a8
Change the include order to resolve some new inter-dependencies.
Mar 6, 2022
72f3957
And match the checks.
Mar 6, 2022
e55f57a
Try fix old a_http includes even more.
Mar 6, 2022
3d89fb0
Add `pawndoc="true"`.
Mar 6, 2022
61501d2
Remove `#define HTTP`.
Mar 7, 2022
5ec4cb3
Move some comments that seemed to cause an issue.
Mar 7, 2022
eff8bfd
Remove empty pawndoc blocks.
Mar 7, 2022
bfb8b6f
`RACECP_TYPE:`
Mar 14, 2022
045fd54
Rename (simplify) the checkpoint tag.
Mar 15, 2022
aafb808
Some more `bool:` return tags.
Mar 16, 2022
2b6b093
Actor `bool:` returns.
Mar 16, 2022
819876e
a_vehicle tags.
Mar 17, 2022
570867e
Another tag.
Mar 17, 2022
92f733a
Make `GetServerVar...` functions aliases for `GetConsoleVar...`.
Mar 18, 2022
2f9dbd3
`__OPEN_MP_VERSION`
Apr 3, 2022
98d7160
More `bool:` return tags.
Apr 8, 2022
bcd211b
More tags
Apr 11, 2022
f058247
Unfortunately callbacks can't have their parameter names changed, so …
Jun 25, 2022
e10ff99
Remove accidental comments from warnings.
Jun 25, 2022
0bf3fc8
Switch strong/weak tag prefixes to `T_`/`t_` - they're less widely us…
Aug 7, 2022
f2d13fd
Move something.
Aug 7, 2022
7b10fd3
`OnPlayerRequestDownload` tag.
Aug 7, 2022
ae862df
Merge remote-tracking branch 'remotes/origin/master' into consistency…
Sep 4, 2022
ceefd22
Back-port weapon slots.
Sep 4, 2022
81ba713
Use weapon slots.
Sep 4, 2022
cf49dbe
More documentation.
Sep 4, 2022
ae3989f
Typo
Sep 4, 2022
c2c58d0
`PLAYER_VARTYPE_`
Sep 4, 2022
8b76202
Prefer `<p/>`
Nov 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,122 @@ The current latest version is **0.3.7-R2-2-1**.

The master branch HEAD does not currently contain any RC libaries.

## Tags

The latest version of the SA:MP includes introduce many more tags to functions and callbacks. These
are useful in the long run, but slightly annoying to upgrade to. There are three symbols:
`NO_TAGS`, `WEAK_TAGS`, and `STRONG_TAGS`; that you can define before including `<a_samp>`, each one
enabling progressively more checks:

```pawn
#define STRONG_TAGS
#include <a_samp>
```

To encourage some adoption, the default is `WEAK_TAGS`. Most old code uses will simply give a
warning when the wrong tag is found:

```pawn
// Gives a warning:
SetPlayerControllable(playerid, 1);

// Should be:
SetPlayerControllable(playerid, true);
```

However, there's a problem - callbacks give an error:

```pawn
forward OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate);

public OnPlayerStateChange(playerid, newstate, oldstate)
{
}
```

This gives an error, when it should be fine. Fixing it in a mode is easy - just use the correct
tags on the variables in the callbacks. Fixing it in a generic library needs a few extra lines to
define a default tag when one isn't found (i.e. the user isn't using the improved includes):

```pawn
#if !defined PLAYER_STATE
// Use the default tag (none, `_:`) when the improved includes aren't found.
#define PLAYER_STATE: _:
#endif
public OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate)
{
return Hooked_OnPlayerStateChange(playerid, newstate, oldstate);
}

// Don't forget to use ALS as normal.
forward Hooked_OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate);
```

### Complete List

* `OnPlayerStateChange`

```pawn
#if !defined PLAYER_STATE
#define PLAYER_STATE: _:
#endif
forward OnPlayerStateChange(playerid, PLAYER_STATE:newstate, PLAYER_STATE:oldstate);
```

* `OnPlayerClickPlayer`

```pawn
#if !defined CLICK_SOURCE
#define CLICK_SOURCE: _:
#endif
forward OnPlayerClickPlayer(playerid, clickedplayerid, CLICK_SOURCE:source);
```

* `OnPlayerEditObject`

```pawn
#if !defined EDIT_RESPONSE
#define EDIT_RESPONSE: _:
#endif
forward OnPlayerEditObject(playerid, playerobject, objectid, EDIT_RESPONSE:response, Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ);
```

* `OnPlayerEditAttachedObject`

```pawn
#if !defined EDIT_RESPONSE
#define EDIT_RESPONSE: _:
#endif
forward OnPlayerEditAttachedObject(playerid, EDIT_RESPONSE:response, index, modelid, boneid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:fRotZ, Float:fScaleX, Float:fScaleY, Float:fScaleZ);
```

* `OnPlayerSelectObject`

```pawn
#if !defined SELECT_OBJECT
#define SELECT_OBJECT: _:
#endif
forward OnPlayerSelectObject(playerid, SELECT_OBJECT:type, objectid, modelid, Float:fX, Float:fY, Float:fZ);
```

* `OnPlayerWeaponShot`

```pawn
#if !defined BULLET_HIT_TYPE
#define BULLET_HIT_TYPE: _:
#endif
forward OnPlayerWeaponShot(playerid, weaponid, BULLET_HIT_TYPE:hittype, hitid, Float:fX, Float:fY, Float:fZ);
```

* `OnPlayerKeyStateChange`

```pawn
#if !defined KEY
#define KEY: _:
#endif
forward OnPlayerKeyStateChange(playerid, KEY:newkeys, KEY:oldkeys);
```

## Why?

The package management system built into the `sampctl` tool is based on GitHub
Expand Down
177 changes: 86 additions & 91 deletions a_actor.inc

Large diffs are not rendered by default.

40 changes: 24 additions & 16 deletions a_http.inc
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,46 @@
// --------------------------------------------------

// HTTP requests
#define HTTP_GET (1)
#define HTTP_POST (2)
#define HTTP_HEAD (3)
#define HTTP_METHOD: __TAG(HTTP_METHOD):
enum HTTP_METHOD:
{
HTTP_GET = 1,
HTTP_POST,
HTTP_HEAD
}

// HTTP error response codes
// These codes compliment ordinary HTTP response codes returned in 'response_code'
// (10x) (20x OK) (30x Moved) (40x Unauthorised) (50x Server Error)
#define HTTP_ERROR_BAD_HOST (1)
#define HTTP_ERROR_NO_SOCKET (2)
#define HTTP_ERROR_CANT_CONNECT (3)
#define HTTP_ERROR_CANT_WRITE (4)
#define HTTP_ERROR_CONTENT_TOO_BIG (5)
#define HTTP_ERROR_MALFORMED_RESPONSE (6)
// These codes compliment ordinary HTTP response codes returned in 'responseCode'
// (10x) (20x OK) (30x Moved) (40x Unauthorised) (50x Server Error)
#define HTTP_ERROR: __TAG(HTTP_ERROR):
enum HTTP_ERROR:
{
HTTP_ERROR_BAD_HOST = 1,
HTTP_ERROR_NO_SOCKET,
HTTP_ERROR_CANT_CONNECT,
HTTP_ERROR_CANT_WRITE,
HTTP_ERROR_CONTENT_TOO_BIG,
HTTP_ERROR_MALFORMED_RESPONSE
}

/// <summary>Sends a threaded HTTP request.</summary>
/// <param name="index">ID used to differentiate requests that are sent to the same callback (useful for playerids)</param>
/// <param name="type">The type of request you wish to send</param>
/// <param name="method">The type of request you wish to send</param>
/// <param name="url">The URL you want to request. (Without 'http://')</param>
/// <param name="data">Any POST data you want to send with the request</param>
/// <param name="callback">Name of the callback function you want to use to handle responses to this request</param>
/// <remarks>This function was added in <b>SA-MP 0.3b</b> and will not work in earlier versions!</remarks>
/// <returns><b><c>1</c></b> on success, <b><c>0</c></b> on failure.</returns>
/// <remarks>
/// <b>Request types:</b><p/>
/// <b>Request types:</b><br />
/// <ul>
/// <li><b><c>HTTP_GET</c></b></li>
/// <li><b><c>HTTP_POST</c></b></li>
/// <li><b><c>HTTP_HEAD</c></b></li>
/// </ul>
/// </remarks>
/// <remarks>
/// <b>Response codes:</b><p/>
/// <b>Response codes:</b><br />
/// <ul>
/// <li><b><c>HTTP_ERROR_BAD_HOST</c></b></li>
/// <li><b><c>HTTP_ERROR_NO_SOCKET</c></b></li>
Expand All @@ -60,7 +68,7 @@
/// <li>+ standard HTTP response codes</li>
/// </ul>
/// </remarks>
native HTTP(index, type, const url[], const data[], const callback[]);
native HTTP(index, HTTP_METHOD:method, const url[], const data[], const callback[]);

// example HTTP callback: public MyHttpResponse(index, response_code, const data[]) { ... }
// example HTTP callback: public MyHttpResponse(index, responseCode, const data[]) { ... }

Loading