Skip to content

Commit

Permalink
Merge pull request #798 from openmultiplayer/amir/no-exceptions
Browse files Browse the repository at this point in the history
New way of handling ParamCast errors instead of throwing exceptions.
  • Loading branch information
AmyrAhmady authored Dec 8, 2023
2 parents c11feac + b69202d commit 66d854f
Show file tree
Hide file tree
Showing 7 changed files with 1,376 additions and 1,285 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// This file should only be included in one place.
#include "pawn.hpp"
#include <Server/Components/Pawn/pawn.hpp>

#if defined PAWN_NATIVES_HAS_FUNC
#include <pawn-natives/NativesMain.hpp>
Expand Down
1,366 changes: 1,366 additions & 0 deletions SDK/include/Server/Components/Pawn/Impl/pawn_natives.hpp

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion SDK/include/Server/Components/Pawn/pawn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <Server/Components/GangZones/gangzones.hpp>
#include <Server/Components/Menus/menus.hpp>
#include <Server/Components/Objects/objects.hpp>
#include <Server/Components/Pawn/pawn.hpp>
#include <Server/Components/Pickups/pickups.hpp>
#include <Server/Components/Recordings/recordings.hpp>
#include <Server/Components/TextDraws/textdraws.hpp>
Expand Down
1,280 changes: 0 additions & 1,280 deletions SDK/include/Server/Components/Pawn/pawn_natives.hpp

This file was deleted.

7 changes: 6 additions & 1 deletion Server/Components/Pawn/Scripting/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "../Manager/Manager.hpp"
#include "Impl.hpp"
#include "sdk.hpp"
#include <Server/Components/Pawn/pawn_natives.hpp>
#include <Server/Components/Pawn/Impl/pawn_natives.hpp>

namespace pawn_natives
{
Expand All @@ -40,6 +40,11 @@ class ParamCast<PawnScript&>
return *value_;
}

bool Error() const
{
return false;
}

static constexpr int Size = 0;

private:
Expand Down
3 changes: 2 additions & 1 deletion Server/Components/Pawn/Scripting/Vehicle/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,10 @@ SCRIPT_API(VehicleCanHaveComponent, bool(int modelid, int componentid))
return Impl::isValidComponentForVehicleModel(modelid, componentid);
}

SCRIPT_API(GetRandomCarColPair, void(int modelid, int& colour1, int& colour2, int& colour3, int& colour4))
SCRIPT_API(GetRandomCarColPair, bool(int modelid, int& colour1, int& colour2, int& colour3, int& colour4))
{
getRandomVehicleColour(modelid, colour1, colour2, colour3, colour4);
return true;
}

SCRIPT_API(CarColIndexToColour, int(int colourIndex, int alpha))
Expand Down
2 changes: 1 addition & 1 deletion lib/pawn-natives

0 comments on commit 66d854f

Please sign in to comment.