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

Add "direction" JS field to Structure objects #3508

Merged
merged 2 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions doc/js-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ In addition, the following properties are defined:
* ```status``` The completeness status of the structure. It will be one of ```BEING_BUILT``` and ```BUILT```.
* ```type``` The type will always be ```STRUCTURE```.
* ```cost``` What it would cost to build this structure. (3.2+ only)
* ```direction``` The direction the structure is facing. (4.5+ only)
* ```stattype``` The stattype defines the type of structure. It will be one of ```HQ```, ```FACTORY```, ```POWER_GEN```,
```RESOURCE_EXTRACTOR```, ```LASSAT```, ```DEFENSE```, ```WALL```, ```RESEARCH_LAB```, ```REPAIR_FACILITY```,
```CYBORG_FACTORY```, ```VTOL_FACTORY```, ```REARM_PAD```, ```SAT_UPLINK```, ```GATE``` and ```COMMAND_CONTROL```.
Expand Down
2 changes: 2 additions & 0 deletions src/quickjs_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@
//;; * ```status``` The completeness status of the structure. It will be one of ```BEING_BUILT``` and ```BUILT```.
//;; * ```type``` The type will always be ```STRUCTURE```.
//;; * ```cost``` What it would cost to build this structure. (3.2+ only)
//;; * ```direction``` The direction the structure is facing. (4.5+ only)
//;; * ```stattype``` The stattype defines the type of structure. It will be one of ```HQ```, ```FACTORY```, ```POWER_GEN```,
//;; ```RESOURCE_EXTRACTOR```, ```LASSAT```, ```DEFENSE```, ```WALL```, ```RESEARCH_LAB```, ```REPAIR_FACILITY```,
//;; ```CYBORG_FACTORY```, ```VTOL_FACTORY```, ```REARM_PAD```, ```SAT_UPLINK```, ```GATE``` and ```COMMAND_CONTROL```.
Expand Down Expand Up @@ -829,12 +830,13 @@
QuickJS_DefinePropertyValue(ctx, value, "status", JS_NewInt32(ctx, (int)psStruct->status), JS_PROP_ENUMERABLE);
QuickJS_DefinePropertyValue(ctx, value, "health", JS_NewInt32(ctx, 100 * psStruct->body / MAX(1, structureBody(psStruct))), JS_PROP_ENUMERABLE);
QuickJS_DefinePropertyValue(ctx, value, "cost", JS_NewInt32(ctx, psStruct->pStructureType->powerToBuild), JS_PROP_ENUMERABLE);
QuickJS_DefinePropertyValue(ctx, value, "direction", JS_NewInt32(ctx, UNDEG(psStruct->rot.direction)), JS_PROP_ENUMERABLE);
int stattype = 0;
switch (psStruct->pStructureType->type) // don't bleed our source insanities into the scripting world
{
case REF_WALL:
case REF_WALLCORNER:
case REF_GATE:

Check warning on line 839 in src/quickjs_backend.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [GCC]

conversion from ‘float’ to ‘int32_t’ {aka ‘int’} may change value [-Wfloat-conversion]

Check warning on line 839 in src/quickjs_backend.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC]

conversion from 'float' to 'int32_t' {aka 'int'} may change value [-Wfloat-conversion]

Check warning on line 839 in src/quickjs_backend.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int32_t' (aka 'int') [-Wfloat-conversion]

Check warning on line 839 in src/quickjs_backend.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC -m32]

conversion from 'float' to 'int32_t' {aka 'int'} may change value [-Wfloat-conversion]

Check warning on line 839 in src/quickjs_backend.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 20.04 [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int32_t' (aka 'int') [-Wfloat-conversion]

Check warning on line 839 in src/quickjs_backend.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int32_t' (aka 'int') [-Wfloat-conversion]
stattype = (int)REF_WALL;
break;
case REF_GENERIC:
Expand Down
Loading