Skip to content

Commit

Permalink
Add IsVehicleHaveUpgrades(model), optimized checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ziggi committed Nov 5, 2016
1 parent ad44928 commit fb1ef4a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ GetVehicleCompatibleTypes(model, array[ZVEH_MAX_COMPONENT_TYPES], &array_size);
GetVehicleComponentName(componentid, cname[], size = sizeof(cname));
GetVehicleCompatibleUpgrades(model, array[ZVEH_MAX_COMPONENTS], &array_size);
IsVehicleUpgradeCompatible(model, componentid);
IsVehicleHaveUpgrades(model);
```

# Directives
Expand Down
14 changes: 11 additions & 3 deletions zvehcomp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ stock GetVehicleCompatibleTypes(model, array[ZVEH_MAX_COMPONENT_TYPES], &array_s
stock GetVehicleComponentName(componentid, cname[], size = sizeof(cname))
{
new index = componentid - 1000;
if (index < 0 || index >= sizeof(gComponentName)) {
if (!(0 <= index < sizeof(gComponentName))) {
return 0;
}

Expand All @@ -2252,7 +2252,7 @@ stock GetVehicleComponentName(componentid, cname[], size = sizeof(cname))

stock GetVehicleCompatibleUpgrades(model, array[ZVEH_MAX_COMPONENTS], &array_size)
{
if (model < 400 || model > 611) {
if (!(400 <= model <= 611)) {
return 0;
}

Expand All @@ -2275,7 +2275,7 @@ stock GetVehicleCompatibleUpgrades(model, array[ZVEH_MAX_COMPONENTS], &array_siz

stock IsVehicleUpgradeCompatible(model, componentid)
{
if (model < 400 || model > 611) {
if (!(400 <= model <= 611)) {
return 0;
}

Expand All @@ -2298,3 +2298,11 @@ stock IsVehicleUpgradeCompatible(model, componentid)

return 0;
}

stock IsVehicleHaveUpgrades(model)
{
if (!(400 <= model <= 611)) {
return 0;
}
return gComponents[model - 400]{0} == ZVEH_INVALID_COMPONENT_ID;
}

0 comments on commit fb1ef4a

Please sign in to comment.