1 /*
2 * OpenBOR - http://www.chronocrash.com
3 * -----------------------------------------------------------------------
4 * All rights reserved. See LICENSE in OpenBOR root for license details.
5 *
6 * Copyright (c) 2004 OpenBOR Team
7 */
8
9 // Axis Properties
10 // 2018-05-13
11 // Caskey, Damon V.
12
13 #include "scriptcommon.h"
14
15 // Use string property argument to find an
16 // integer property constant and populate
17 // varlist->lval.
mapstrings_axis_plane_lateral_property(ScriptVariant ** varlist,int paramCount)18 int mapstrings_axis_plane_lateral_property(ScriptVariant **varlist, int paramCount)
19 {
20 #define ARG_MINIMUM 2 // Minimum number of arguments allowed in varlist.
21 #define ARG_PROPERTY 1 // Varlist element carrying which property is requested.
22
23 char *propname = NULL; // Placeholder for string property name from varlist.
24 int prop; // Placeholder for integer constant located by string.
25
26 static const char *proplist[] =
27 {
28 "x",
29 "z"
30 };
31
32 // If the minimum argument count
33 // was not passed, then there is
34 // nothing to map. Return true - we'll
35 // catch the mistake in property access
36 // functions.
37 if(paramCount < ARG_MINIMUM)
38 {
39 return 1;
40 }
41
42 // See macro - will return 0 on fail.
43 MAPSTRINGS(varlist[ARG_PROPERTY], proplist, _AXIS_PLANE_LATERAL_END,
44 "Property name '%s' is not supported by axis lateral plane.\n");
45
46
47 // If we made it this far everything should be OK.
48 return 1;
49
50 #undef ARG_MINIMUM
51 #undef ARG_PROPERTY
52 }
53
54 // Use string property argument to find an
55 // integer property constant and populate
56 // varlist->lval.
mapstrings_axis_plane_vertical_property(ScriptVariant ** varlist,int paramCount)57 int mapstrings_axis_plane_vertical_property(ScriptVariant **varlist, int paramCount)
58 {
59 #define ARG_MINIMUM 2 // Minimum number of arguments allowed in varlist.
60 #define ARG_PROPERTY 1 // Varlist element carrying which property is requested.
61
62 char *propname = NULL; // Placeholder for string property name from varlist.
63 int prop; // Placeholder for integer constant located by string.
64
65 static const char *proplist[] =
66 {
67 "x",
68 "y"
69 };
70
71 // If the minimum argument count
72 // was not passed, then there is
73 // nothing to map. Return true - we'll
74 // catch the mistake in property access
75 // functions.
76 if(paramCount < ARG_MINIMUM)
77 {
78 return 1;
79 }
80
81 // See macro - will return 0 on fail.
82 MAPSTRINGS(varlist[ARG_PROPERTY], proplist, _AXIS_PLANE_VERTICAL_END,
83 "Property name '%s' is not supported by axis vertical plane.\n");
84
85
86 // If we made it this far everything should be OK.
87 return 1;
88
89 #undef ARG_MINIMUM
90 #undef ARG_PROPERTY
91 }
92
93 // Use string property argument to find an
94 // integer property constant and populate
95 // varlist->lval.
mapstrings_axis_principal_property(ScriptVariant ** varlist,int paramCount)96 int mapstrings_axis_principal_property(ScriptVariant **varlist, int paramCount)
97 {
98 #define ARG_MINIMUM 2 // Minimum number of arguments allowed in varlist.
99 #define ARG_PROPERTY 1 // Varlist element carrying which property is requested.
100
101 char *propname = NULL; // Placeholder for string property name from varlist.
102 int prop; // Placeholder for integer constant located by string.
103
104 static const char *proplist[] =
105 {
106 "x",
107 "y",
108 "z"
109 };
110
111 // If the minimum argument count
112 // was not passed, then there is
113 // nothing to map. Return true - we'll
114 // catch the mistake in property access
115 // functions.
116 if(paramCount < ARG_MINIMUM)
117 {
118 return 1;
119 }
120
121 // See macro - will return 0 on fail.
122 MAPSTRINGS(varlist[ARG_PROPERTY], proplist, _AXIS_PRINCIPAL_END,
123 "Property name '%s' is not supported by axis principal.\n");
124
125
126 // If we made it this far everything should be OK.
127 return 1;
128
129 #undef ARG_MINIMUM
130 #undef ARG_PROPERTY
131 }
132
133 // Caskey, Damon V.
134 // 2018-05-14
135 //
136 // Return an axis property. Requires
137 // the handle from axis property
138 // and property name to access.
openbor_get_axis_plane_lateral_float_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)139 HRESULT openbor_get_axis_plane_lateral_float_property(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount)
140 {
141 #define SELF_NAME "openbor_get_axis_plane_lateral_float_property(void handle, char property)"
142 #define ARG_MINIMUM 2 // Minimum required arguments.
143 #define ARG_HANDLE 0 // Handle (pointer to property structure).
144 #define ARG_PROPERTY 1 // Property to access.
145
146 s_axis_plane_lateral_float *handle = NULL; // Property handle.
147 e_axis_plane_lateral_properties property = 0; // Property argument.
148
149 // Clear pass by reference argument used to send
150 // property data back to calling script. .
151 ScriptVariant_Clear(*pretvar);
152
153 // Map string property name to a
154 // matching integer constant.
155 mapstrings_axis_plane_lateral_property(varlist, paramCount);
156
157 // Verify arguments. There should at least
158 // be a pointer for the property handle and an integer
159 // to determine which property constant is accessed.
160 if(paramCount < ARG_MINIMUM
161 || varlist[ARG_HANDLE]->vt != VT_PTR
162 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
163 {
164 *pretvar = NULL;
165 goto error_local;
166 }
167 else
168 {
169 // Populate local vars for readability.
170 handle = (s_axis_plane_lateral_float *)varlist[ARG_HANDLE]->ptrVal;
171 property = (LONG)varlist[ARG_PROPERTY]->lVal;
172 }
173
174 // All values are float (DOUBLE) type.
175 ScriptVariant_ChangeType(*pretvar, VT_DECIMAL);
176
177 switch(property)
178 {
179 case _AXIS_PLANE_LATERAL_X:
180
181 (*pretvar)->dblVal = (DOUBLE)handle->x;
182
183 break;
184
185 case _AXIS_PLANE_LATERAL_Z:
186
187 (*pretvar)->dblVal = (DOUBLE)handle->z;
188
189 break;
190
191 default:
192
193 printf("Unsupported property.\n");
194 goto error_local;
195
196 break;
197 }
198
199 return S_OK;
200
201 error_local:
202
203 printf("You must provide a valid handle and property name: " SELF_NAME "\n");
204 *pretvar = NULL;
205
206 return E_FAIL;
207
208 #undef SELF_NAME
209 #undef ARG_MINIMUM
210 #undef ARG_HANDLE
211 #undef ARG_INDEX
212 }
213
214
215 // Caskey, Damon V.
216 // 2018-05-14
217 //
218 // Return an axis property. Requires
219 // the handle from axis property
220 // and property name to access.
openbor_get_axis_plane_lateral_int_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)221 HRESULT openbor_get_axis_plane_lateral_int_property(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount)
222 {
223 #define SELF_NAME "openbor_get_axis_plane_lateral_int_property(void handle, char property)"
224 #define ARG_MINIMUM 2 // Minimum required arguments.
225 #define ARG_HANDLE 0 // Handle (pointer to property structure).
226 #define ARG_PROPERTY 1 // Property to access.
227
228 s_axis_plane_lateral_int *handle = NULL; // Property handle.
229 e_axis_plane_lateral_properties property = 0; // Property argument.
230
231 // Clear pass by reference argument used to send
232 // property data back to calling script. .
233 ScriptVariant_Clear(*pretvar);
234
235 // Map string property name to a
236 // matching integer constant.
237 mapstrings_axis_plane_lateral_property(varlist, paramCount);
238
239 // Verify arguments. There should at least
240 // be a pointer for the property handle and an integer
241 // to determine which property constant is accessed.
242 if(paramCount < ARG_MINIMUM
243 || varlist[ARG_HANDLE]->vt != VT_PTR
244 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
245 {
246 *pretvar = NULL;
247 goto error_local;
248 }
249 else
250 {
251 // Populate local vars for readability.
252 handle = (s_axis_plane_lateral_int *)varlist[ARG_HANDLE]->ptrVal;
253 property = (LONG)varlist[ARG_PROPERTY]->lVal;
254 }
255
256 // All values are float (DOUBLE) type.
257 ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
258
259 switch(property)
260 {
261 case _AXIS_PLANE_LATERAL_X:
262
263 (*pretvar)->lVal = (LONG)handle->x;
264
265 break;
266
267 case _AXIS_PLANE_LATERAL_Z:
268
269 (*pretvar)->lVal = (LONG)handle->z;
270
271 break;
272
273 default:
274
275 printf("Unsupported property.\n");
276 goto error_local;
277
278 break;
279 }
280
281 return S_OK;
282
283 error_local:
284
285 printf("You must provide a valid handle and property name: " SELF_NAME "\n");
286 *pretvar = NULL;
287
288 return E_FAIL;
289
290 #undef SELF_NAME
291 #undef ARG_MINIMUM
292 #undef ARG_HANDLE
293 #undef ARG_INDEX
294 }
295
296 // Caskey, Damon V.
297 // 2018-05-14
298 //
299 // Return an axis property. Requires
300 // the handle from axis property
301 // and property name to access.
openbor_get_axis_principal_float_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)302 HRESULT openbor_get_axis_principal_float_property(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount)
303 {
304 #define SELF_NAME "openbor_get_axis_principal_float_property(void handle, char property)"
305 #define ARG_MINIMUM 2 // Minimum required arguments.
306 #define ARG_HANDLE 0 // Handle (pointer to property structure).
307 #define ARG_PROPERTY 1 // Property to access.
308
309 s_axis_principal_float *handle = NULL; // Property handle.
310 e_axis_principal_properties property = 0; // Property argument.
311
312 // Clear pass by reference argument used to send
313 // property data back to calling script. .
314 ScriptVariant_Clear(*pretvar);
315
316 // Map string property name to a
317 // matching integer constant.
318 mapstrings_axis_principal_property(varlist, paramCount);
319
320 // Verify arguments. There should at least
321 // be a pointer for the property handle and an integer
322 // to determine which property constant is accessed.
323 if(paramCount < ARG_MINIMUM
324 || varlist[ARG_HANDLE]->vt != VT_PTR
325 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
326 {
327 *pretvar = NULL;
328 goto error_local;
329 }
330 else
331 {
332 // Populate local vars for readability.
333 handle = (s_axis_principal_float *)varlist[ARG_HANDLE]->ptrVal;
334 property = (LONG)varlist[ARG_PROPERTY]->lVal;
335 }
336
337 // All values are float (DOUBLE) type.
338 ScriptVariant_ChangeType(*pretvar, VT_DECIMAL);
339
340 switch(property)
341 {
342 case _AXIS_PRINCIPAL_X:
343
344 (*pretvar)->dblVal = (DOUBLE)handle->x;
345
346 break;
347
348 case _AXIS_PRINCIPAL_Y:
349
350 (*pretvar)->dblVal = (DOUBLE)handle->y;
351
352 break;
353
354 case _AXIS_PRINCIPAL_Z:
355
356 (*pretvar)->dblVal = (DOUBLE)handle->z;
357
358 break;
359
360 default:
361
362 printf("Unsupported property.\n");
363 goto error_local;
364
365 break;
366 }
367
368 return S_OK;
369
370 error_local:
371
372 printf("You must provide a valid handle and property name: " SELF_NAME "\n");
373 *pretvar = NULL;
374
375 return E_FAIL;
376
377 #undef SELF_NAME
378 #undef ARG_MINIMUM
379 #undef ARG_HANDLE
380 #undef ARG_INDEX
381 }
382
383 // Caskey, Damon V.
384 // 2018-05-14
385 //
386 // Return an axis property. Requires
387 // the handle from axis property
388 // and property name to access.
openbor_get_axis_principal_int_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)389 HRESULT openbor_get_axis_principal_int_property(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount)
390 {
391 #define SELF_NAME "openbor_get_axis_principal_int_property(void handle, char property)"
392 #define ARG_MINIMUM 2 // Minimum required arguments.
393 #define ARG_HANDLE 0 // Handle (pointer to property structure).
394 #define ARG_PROPERTY 1 // Property to access.
395
396 s_axis_principal_int *handle = NULL; // Property handle.
397 e_axis_principal_properties property = 0; // Property argument.
398
399 // Clear pass by reference argument used to send
400 // property data back to calling script. .
401 ScriptVariant_Clear(*pretvar);
402
403 // Map string property name to a
404 // matching integer constant.
405 mapstrings_axis_principal_property(varlist, paramCount);
406
407 // Verify arguments. There should at least
408 // be a pointer for the property handle and an integer
409 // to determine which property constant is accessed.
410 if(paramCount < ARG_MINIMUM
411 || varlist[ARG_HANDLE]->vt != VT_PTR
412 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
413 {
414 *pretvar = NULL;
415 goto error_local;
416 }
417 else
418 {
419 // Populate local vars for readability.
420 handle = (s_axis_principal_int *)varlist[ARG_HANDLE]->ptrVal;
421 property = (LONG)varlist[ARG_PROPERTY]->lVal;
422 }
423
424 // All values are float (DOUBLE) type.
425 ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
426
427 switch(property)
428 {
429 case _AXIS_PRINCIPAL_X:
430
431 (*pretvar)->lVal = (LONG)handle->x;
432
433 break;
434
435 case _AXIS_PRINCIPAL_Y:
436
437 (*pretvar)->lVal = (LONG)handle->y;
438
439 break;
440
441 case _AXIS_PRINCIPAL_Z:
442
443 (*pretvar)->lVal = (LONG)handle->z;
444
445 break;
446
447 default:
448
449 printf("Unsupported property.\n");
450 goto error_local;
451
452 break;
453 }
454
455 return S_OK;
456
457 error_local:
458
459 printf("You must provide a valid handle and property name: " SELF_NAME "\n");
460 *pretvar = NULL;
461
462 return E_FAIL;
463
464 #undef SELF_NAME
465 #undef ARG_MINIMUM
466 #undef ARG_HANDLE
467 #undef ARG_INDEX
468 }
469
470 // Caskey, Damon V.
471 // 2018-05-14
472 //
473 // Return an axis property. Requires
474 // the handle from axis property
475 // and property name to access.
openbor_get_axis_plane_vertical_int_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)476 HRESULT openbor_get_axis_plane_vertical_int_property(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount)
477 {
478 #define SELF_NAME "openbor_get_axis_plane_vertical_int_property(void handle, char property)"
479 #define ARG_MINIMUM 2 // Minimum required arguments.
480 #define ARG_HANDLE 0 // Handle (pointer to property structure).
481 #define ARG_PROPERTY 1 // Property to access.
482
483 s_axis_plane_vertical_int *handle = NULL; // Property handle.
484 e_axis_plane_vertical_properties property = 0; // Property argument.
485
486 // Clear pass by reference argument used to send
487 // property data back to calling script. .
488 ScriptVariant_Clear(*pretvar);
489
490 // Map string property name to a
491 // matching integer constant.
492 mapstrings_axis_plane_vertical_property(varlist, paramCount);
493
494 // Verify arguments. There should at least
495 // be a pointer for the property handle and an integer
496 // to determine which property constant is accessed.
497 if(paramCount < ARG_MINIMUM
498 || varlist[ARG_HANDLE]->vt != VT_PTR
499 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
500 {
501 *pretvar = NULL;
502 goto error_local;
503 }
504 else
505 {
506 // Populate local vars for readability.
507 handle = (s_axis_plane_vertical_int *)varlist[ARG_HANDLE]->ptrVal;
508 property = (LONG)varlist[ARG_PROPERTY]->lVal;
509 }
510
511 // All values are float (DOUBLE) type.
512 ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
513
514 switch(property)
515 {
516 case _AXIS_PLANE_VERTICAL_X:
517
518 (*pretvar)->lVal = (LONG)handle->x;
519
520 break;
521
522 case _AXIS_PLANE_VERTICAL_Y:
523
524 (*pretvar)->lVal = (LONG)handle->y;
525
526 break;
527
528 default:
529
530 printf("Unsupported property.\n");
531 goto error_local;
532
533 break;
534 }
535
536 return S_OK;
537
538 error_local:
539
540 printf("You must provide a valid handle and property name: " SELF_NAME "\n");
541 *pretvar = NULL;
542
543 return E_FAIL;
544
545 #undef SELF_NAME
546 #undef ARG_MINIMUM
547 #undef ARG_HANDLE
548 #undef ARG_INDEX
549 }
550
551 // Caskey, Damon V.
552 // 2018-05-14
553 //
554 // Mutate an axis property. Requires
555 // the handle from axis property, property
556 // name to modify, and the new value.
openbor_set_axis_plane_lateral_float_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)557 HRESULT openbor_set_axis_plane_lateral_float_property(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
558 {
559 #define SELF_NAME "openbor_set_axis_plane_lateral_float_property(void handle, char property, value)"
560 #define ARG_MINIMUM 3 // Minimum required arguments.
561 #define ARG_HANDLE 0 // Handle (pointer to property structure).
562 #define ARG_PROPERTY 1 // Property to access.
563 #define ARG_VALUE 2 // New value to apply.
564
565 int result = S_OK; // Success or error?
566 s_axis_plane_lateral_float *handle = NULL; // Property handle.
567 e_axis_plane_lateral_properties property = 0; // Property to access.
568
569 // Value carriers to apply on properties after
570 // taken from argument.
571 DOUBLE temp_double;
572
573 // Map string property name to a
574 // matching integer constant.
575 mapstrings_axis_plane_lateral_property(varlist, paramCount);
576
577 // Verify incoming arguments. There should at least
578 // be a pointer for the property handle and an integer
579 // to determine which property is accessed.
580 if(paramCount < ARG_MINIMUM
581 || varlist[ARG_HANDLE]->vt != VT_PTR
582 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
583 {
584 *pretvar = NULL;
585 goto error_local;
586 }
587
588 // Populate local handle and property vars.
589 handle = (s_axis_plane_lateral_float *)varlist[ARG_HANDLE]->ptrVal;
590 property = (LONG)varlist[ARG_PROPERTY]->lVal;
591
592 // All values are same type for this property set,
593 // so we can copy to temp var right here.
594 if(!SUCCEEDED(ScriptVariant_DecimalValue(varlist[ARG_VALUE], &temp_double)))
595 {
596 goto error_local;
597 }
598
599 // Which property to modify?
600 switch(property)
601 {
602
603 case _AXIS_PLANE_LATERAL_X:
604
605 handle->x = temp_double;
606
607 break;
608
609 case _AXIS_PLANE_LATERAL_Z:
610
611 handle->z = temp_double;
612
613 break;
614
615 default:
616
617 printf("Unsupported property.\n");
618 goto error_local;
619
620 break;
621 }
622
623 return result;
624
625 // Error trapping.
626 error_local:
627
628 printf("You must provide a valid binding handle, property, and new value: " SELF_NAME "\n");
629
630 result = E_FAIL;
631 return result;
632
633 #undef SELF_NAME
634 #undef ARG_MINIMUM
635 #undef ARG_HANDLE
636 #undef ARG_PROPERTY
637 #undef ARG_VALUE
638 }
639
640 // Caskey, Damon V.
641 // 2018-05-14
642 //
643 // Mutate an axis property. Requires
644 // the handle from axis property, property
645 // name to modify, and the new value.
openbor_set_axis_plane_lateral_int_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)646 HRESULT openbor_set_axis_plane_lateral_int_property(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
647 {
648 #define SELF_NAME "openbor_set_axis_plane_lateral_float_property(void handle, char property, value)"
649 #define ARG_MINIMUM 3 // Minimum required arguments.
650 #define ARG_HANDLE 0 // Handle (pointer to property structure).
651 #define ARG_PROPERTY 1 // Property to access.
652 #define ARG_VALUE 2 // New value to apply.
653
654 int result = S_OK; // Success or error?
655 s_axis_plane_lateral_int *handle = NULL; // Property handle.
656 e_axis_plane_lateral_properties property = 0; // Property to access.
657
658 // Value carriers to apply on properties after
659 // taken from argument.
660 LONG temp_int;
661
662 // Map string property name to a
663 // matching integer constant.
664 mapstrings_axis_plane_lateral_property(varlist, paramCount);
665
666 // Verify incoming arguments. There should at least
667 // be a pointer for the property handle and an integer
668 // to determine which property is accessed.
669 if(paramCount < ARG_MINIMUM
670 || varlist[ARG_HANDLE]->vt != VT_PTR
671 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
672 {
673 *pretvar = NULL;
674 goto error_local;
675 }
676
677 // Populate local handle and property vars.
678 handle = (s_axis_plane_lateral_int *)varlist[ARG_HANDLE]->ptrVal;
679 property = (LONG)varlist[ARG_PROPERTY]->lVal;
680
681 // All values are same type for this property set,
682 // so we can copy to temp var right here.
683 if(!SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
684 {
685 goto error_local;
686 }
687
688 // Which property to modify?
689 switch(property)
690 {
691
692 case _AXIS_PLANE_LATERAL_X:
693
694 handle->x = temp_int;
695
696 break;
697
698 case _AXIS_PLANE_LATERAL_Z:
699
700 handle->z = temp_int;
701
702 break;
703
704 default:
705
706 printf("Unsupported property.\n");
707 goto error_local;
708
709 break;
710 }
711
712 return result;
713
714 // Error trapping.
715 error_local:
716
717 printf("You must provide a valid binding handle, property, and new value: " SELF_NAME "\n");
718
719 result = E_FAIL;
720 return result;
721
722 #undef SELF_NAME
723 #undef ARG_MINIMUM
724 #undef ARG_HANDLE
725 #undef ARG_PROPERTY
726 #undef ARG_VALUE
727 }
728
729 // Caskey, Damon V.
730 // 2018-05-14
731 //
732 // Mutate an axis property. Requires
733 // the handle from axis property, property
734 // name to modify, and the new value.
openbor_set_axis_principal_float_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)735 HRESULT openbor_set_axis_principal_float_property(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
736 {
737 #define SELF_NAME "openbor_set_axis_principal_float_property(void handle, char property, value)"
738 #define ARG_MINIMUM 3 // Minimum required arguments.
739 #define ARG_HANDLE 0 // Handle (pointer to property structure).
740 #define ARG_PROPERTY 1 // Property to access.
741 #define ARG_VALUE 2 // New value to apply.
742
743 int result = S_OK; // Success or error?
744 s_axis_principal_float *handle = NULL; // Property handle.
745 e_axis_principal_properties property = 0; // Property to access.
746
747 // Value carriers to apply on properties after
748 // taken from argument.
749 DOUBLE temp_double;
750
751 // Map string property name to a
752 // matching integer constant.
753 mapstrings_axis_plane_lateral_property(varlist, paramCount);
754
755 // Verify incoming arguments. There should at least
756 // be a pointer for the property handle and an integer
757 // to determine which property is accessed.
758 if(paramCount < ARG_MINIMUM
759 || varlist[ARG_HANDLE]->vt != VT_PTR
760 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
761 {
762 *pretvar = NULL;
763 goto error_local;
764 }
765
766 // Populate local handle and property vars.
767 handle = (s_axis_principal_float *)varlist[ARG_HANDLE]->ptrVal;
768 property = (LONG)varlist[ARG_PROPERTY]->lVal;
769
770 // All values are same type for this property set,
771 // so we can copy to temp var right here.
772 if(!SUCCEEDED(ScriptVariant_DecimalValue(varlist[ARG_VALUE], &temp_double)))
773 {
774 goto error_local;
775 }
776
777 // Which property to modify?
778 switch(property)
779 {
780
781 case _AXIS_PRINCIPAL_X:
782
783 handle->x = temp_double;
784
785 break;
786
787 case _AXIS_PRINCIPAL_Y:
788
789 handle->y = temp_double;
790
791 break;
792
793 case _AXIS_PRINCIPAL_Z:
794
795 handle->z = temp_double;
796
797 break;
798
799 default:
800
801 printf("Unsupported property.\n");
802 goto error_local;
803
804 break;
805 }
806
807 return result;
808
809 // Error trapping.
810 error_local:
811
812 printf("You must provide a valid binding handle, property, and new value: " SELF_NAME "\n");
813
814 result = E_FAIL;
815 return result;
816
817 #undef SELF_NAME
818 #undef ARG_MINIMUM
819 #undef ARG_HANDLE
820 #undef ARG_PROPERTY
821 #undef ARG_VALUE
822 }
823
824 // Caskey, Damon V.
825 // 2018-05-14
826 //
827 // Mutate an axis property. Requires
828 // the handle from axis property, property
829 // name to modify, and the new value.
openbor_set_axis_principal_int_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)830 HRESULT openbor_set_axis_principal_int_property(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
831 {
832 #define SELF_NAME "openbor_set_axis_principal_int_property(void handle, char property, value)"
833 #define ARG_MINIMUM 3 // Minimum required arguments.
834 #define ARG_HANDLE 0 // Handle (pointer to property structure).
835 #define ARG_PROPERTY 1 // Property to access.
836 #define ARG_VALUE 2 // New value to apply.
837
838 int result = S_OK; // Success or error?
839 s_axis_principal_int *handle = NULL; // Property handle.
840 e_axis_principal_properties property = 0; // Property to access.
841
842 // Value carriers to apply on properties after
843 // taken from argument.
844 LONG temp_int;
845
846 // Map string property name to a
847 // matching integer constant.
848 mapstrings_axis_plane_lateral_property(varlist, paramCount);
849
850 // Verify incoming arguments. There should at least
851 // be a pointer for the property handle and an integer
852 // to determine which property is accessed.
853 if(paramCount < ARG_MINIMUM
854 || varlist[ARG_HANDLE]->vt != VT_PTR
855 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
856 {
857 *pretvar = NULL;
858 goto error_local;
859 }
860
861 // Populate local handle and property vars.
862 handle = (s_axis_principal_int *)varlist[ARG_HANDLE]->ptrVal;
863 property = (LONG)varlist[ARG_PROPERTY]->lVal;
864
865 // All values are same type for this property set,
866 // so we can copy to temp var right here.
867 if(!SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
868 {
869 goto error_local;
870 }
871
872 // Which property to modify?
873 switch(property)
874 {
875
876 case _AXIS_PRINCIPAL_X:
877
878 handle->x = temp_int;
879
880 break;
881
882 case _AXIS_PRINCIPAL_Y:
883
884 handle->y = temp_int;
885
886 break;
887
888 case _AXIS_PRINCIPAL_Z:
889
890 handle->z = temp_int;
891
892 break;
893
894 default:
895
896 printf("Unsupported property.\n");
897 goto error_local;
898
899 break;
900 }
901
902 return result;
903
904 // Error trapping.
905 error_local:
906
907 printf("You must provide a valid binding handle, property, and new value: " SELF_NAME "\n");
908
909 result = E_FAIL;
910 return result;
911
912 #undef SELF_NAME
913 #undef ARG_MINIMUM
914 #undef ARG_HANDLE
915 #undef ARG_PROPERTY
916 #undef ARG_VALUE
917 }
918
919 // Caskey, Damon V.
920 // 2018-05-14
921 //
922 // Mutate an axis property. Requires
923 // the handle from axis property, property
924 // name to modify, and the new value.
openbor_set_axis_plane_vertical_int_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)925 HRESULT openbor_set_axis_plane_vertical_int_property(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
926 {
927 #define SELF_NAME "openbor_set_axis_plane_vertical_int_property(void handle, char property, value)"
928 #define ARG_MINIMUM 3 // Minimum required arguments.
929 #define ARG_HANDLE 0 // Handle (pointer to property structure).
930 #define ARG_PROPERTY 1 // Property to access.
931 #define ARG_VALUE 2 // New value to apply.
932
933 int result = S_OK; // Success or error?
934 s_axis_plane_vertical_int *handle = NULL; // Property handle.
935 e_axis_plane_vertical_properties property = 0; // Property to access.
936
937 // Value carriers to apply on properties after
938 // taken from argument.
939 LONG temp_int;
940
941 // Map string property name to a
942 // matching integer constant.
943 mapstrings_axis_plane_vertical_property(varlist, paramCount);
944
945 // Verify incoming arguments. There should at least
946 // be a pointer for the property handle and an integer
947 // to determine which property is accessed.
948 if(paramCount < ARG_MINIMUM
949 || varlist[ARG_HANDLE]->vt != VT_PTR
950 || varlist[ARG_PROPERTY]->vt != VT_INTEGER)
951 {
952 *pretvar = NULL;
953 goto error_local;
954 }
955
956 // Populate local handle and property vars.
957 handle = (s_axis_plane_vertical_int *)varlist[ARG_HANDLE]->ptrVal;
958 property = (LONG)varlist[ARG_PROPERTY]->lVal;
959
960 // All values are same type for this property set,
961 // so we can copy to temp var right here.
962 if(!SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
963 {
964 goto error_local;
965 }
966
967 // Which property to modify?
968 switch(property)
969 {
970
971 case _AXIS_PLANE_VERTICAL_X:
972
973 handle->x = temp_int;
974
975 break;
976
977 case _AXIS_PLANE_VERTICAL_Y:
978
979 handle->y = temp_int;
980
981 break;
982
983 default:
984
985 printf("Unsupported property.\n");
986 goto error_local;
987
988 break;
989 }
990
991 return result;
992
993 // Error trapping.
994 error_local:
995
996 printf("You must provide a valid binding handle, property, and new value: " SELF_NAME "\n");
997
998 result = E_FAIL;
999 return result;
1000
1001 #undef SELF_NAME
1002 #undef ARG_MINIMUM
1003 #undef ARG_HANDLE
1004 #undef ARG_PROPERTY
1005 #undef ARG_VALUE
1006 }
1007
1008