Skip to content
This repository was archived by the owner on Oct 30, 2020. It is now read-only.

Commit 2ffa774

Browse files
committed
Add beacon-related functions.
1 parent a3de131 commit 2ffa774

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

dogma.c

+39
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,13 @@ ZEND_ARG_INFO(0, attributeid)
280280
ZEND_ARG_INFO(1, out)
281281
ZEND_END_ARG_INFO()
282282

283+
ZEND_BEGIN_ARG_INFO(arginfo_get_area_beacon_attribute, 0)
284+
ZEND_ARG_INFO(0, context)
285+
ZEND_ARG_INFO(0, key)
286+
ZEND_ARG_INFO(0, attributeid)
287+
ZEND_ARG_INFO(1, out)
288+
ZEND_END_ARG_INFO()
289+
283290
ZEND_BEGIN_ARG_INFO(arginfo_get_character_attribute, 0)
284291
ZEND_ARG_INFO(0, context)
285292
ZEND_ARG_INFO(0, attributeid)
@@ -473,6 +480,7 @@ const zend_function_entry dogma_functions[] = {
473480
DEF_DOGMA_FE(set_squad_booster)
474481

475482
DEF_DOGMA_FE(get_location_attribute)
483+
DEF_DOGMA_FE(get_area_beacon_attribute)
476484
DEF_DOGMA_FE(get_character_attribute)
477485
DEF_DOGMA_FE(get_implant_attribute)
478486
DEF_DOGMA_FE(get_skill_attribute)
@@ -571,6 +579,16 @@ static inline int dogma_get_location_from_zval(zval* zloc, dogma_location_t* loc
571579
}
572580
}
573581

582+
if(zend_hash_find(Z_ARRVAL_P(zloc), "area_beacon_index",
583+
sizeof("area_beacon_index"), (void**)&val) == SUCCESS) {
584+
if(Z_TYPE_PP(val) == IS_LONG) {
585+
loc->area_beacon_index = (dogma_key_t)Z_LVAL_PP(val);
586+
} else {
587+
zend_error(E_WARNING, "area_beacon_index is not an integer");
588+
success = 0;
589+
}
590+
}
591+
574592
if(zend_hash_find(Z_ARRVAL_P(zloc), "skill_typeid",
575593
sizeof("skill_typeid"), (void**)&val) == SUCCESS) {
576594
if(Z_TYPE_PP(val) == IS_LONG) {
@@ -622,6 +640,7 @@ PHP_MINIT_FUNCTION(dogma) {
622640
DEF_DOGMA_CONSTANT(DOGMA_LOC_Module);
623641
DEF_DOGMA_CONSTANT(DOGMA_LOC_Charge);
624642
DEF_DOGMA_CONSTANT(DOGMA_LOC_Drone);
643+
DEF_DOGMA_CONSTANT(DOGMA_LOC_Area_Beacon);
625644

626645
DEF_DOGMA_CONSTANT(DOGMA_STATE_Unplugged);
627646
DEF_DOGMA_CONSTANT(DOGMA_STATE_Offline);
@@ -1305,6 +1324,26 @@ ZEND_FUNCTION(dogma_get_location_attribute) {
13051324
RETURN_LONG(ret);
13061325
}
13071326

1327+
ZEND_FUNCTION(dogma_get_area_beacon_attribute) {
1328+
zval* zctx;
1329+
dogma_context_t* ctx;
1330+
long key;
1331+
long attribute;
1332+
zval* zout;
1333+
double out;
1334+
int ret;
1335+
1336+
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllz", &zctx, &key, &attribute, &zout) == FAILURE) {
1337+
RETURN_FALSE;
1338+
}
1339+
GET_CTX(zctx, ctx);
1340+
1341+
ret = dogma_get_area_beacon_attribute(ctx, (dogma_key_t)key, (dogma_attributeid_t)attribute, &out);
1342+
convert_to_null(zout);
1343+
ZVAL_DOUBLE(zout, out);
1344+
RETURN_LONG(ret);
1345+
}
1346+
13081347
ZEND_FUNCTION(dogma_get_character_attribute) {
13091348
zval* zctx;
13101349
dogma_context_t* ctx;

php_dogma.h

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ZEND_FUNCTION(dogma_set_wing_booster);
8989
ZEND_FUNCTION(dogma_set_squad_booster);
9090

9191
ZEND_FUNCTION(dogma_get_location_attribute);
92+
ZEND_FUNCTION(dogma_get_area_beacon_attribute);
9293
ZEND_FUNCTION(dogma_get_character_attribute);
9394
ZEND_FUNCTION(dogma_get_implant_attribute);
9495
ZEND_FUNCTION(dogma_get_skill_attribute);

test-extra.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
$duration, $tracking, $discharge,
4242
$range, $falloff, $usagechance
4343
) === DOGMA_OK);
44-
assert($falloff === 7500.0);
44+
assert($falloff === 11287.5);
4545
assert($range === 1200.0);
4646
assert($discharge === 0.0);
4747

0 commit comments

Comments
 (0)