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 - 2017 OpenBOR Team
7  */
8 
9  // Drawmethod Properties
10  // 2019-03-28
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_drawmethod(ScriptVariant ** varlist,int paramCount)18 int mapstrings_drawmethod(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 		"alpha",
29 		"background_transparency",
30 		"center_x",
31 		"center_y",
32 		"channel_blue",
33 		"channel_green",
34 		"channel_red",
35 		"clip_position_x",
36 		"clip_position_y",
37 		"clip_size_x",
38 		"clip_size_y",
39 		"colorset_index",
40 		"colorset_table",
41 		"enable",
42 		"fill_color",
43 		"flip_x",
44 		"flip_y",
45 		"repeat_x",
46 		"repeat_y",
47 		"rotate",
48 		"rotate_flip",
49 		"scale_x",
50 		"scale_y",
51 		"shift_x",
52 		"span_x",
53 		"span_y",
54 		"tag",
55 		"tint_color",
56 		"tint_mode",
57 		"water_mode",
58 		"water_perspective",
59 		"water_size_begin",
60 		"water_size_end",
61 		"water_wave_amplitude",
62 		"water_wave_length",
63 		"water_wave_speed",
64 		"water_wave_time"
65 	};
66 
67 	// If the minimum argument count
68 	// was not passed, then there is
69 	// nothing to map. Return true - we'll
70 	// catch the mistake in property access
71 	// functions.
72 	if (paramCount < ARG_MINIMUM)
73 	{
74 		return 1;
75 	}
76 
77 	// See macro - will return 0 on fail.
78 	MAPSTRINGS(varlist[ARG_PROPERTY], proplist, _DRAWMETHOD_END,
79 		"Property name '%s' is not supported by drawmethod.\n");
80 
81 
82 	// If we made it this far everything should be OK.
83 	return 1;
84 
85 #undef ARG_MINIMUM
86 #undef ARG_PROPERTY
87 }
88 
89 // Caskey, Damon  V.
90 // 2019-04-15
91 //
92 // Allocate a new drawmethod and return the pointer.
openbor_allocate_drawmethod(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)93 HRESULT openbor_allocate_drawmethod(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
94 {
95 	extern s_drawmethod *allocate_drawmethod();
96 	s_drawmethod *drawmethod;
97 
98 	ScriptVariant_ChangeType(*pretvar, VT_PTR);
99 
100 	if ((drawmethod = allocate_drawmethod()))
101 	{
102 		(*pretvar)->ptrVal = (s_drawmethod *)drawmethod;
103 	}
104 
105 	return S_OK;
106 }
107 
108 // Caskey, Damon  V.
109 // 2019-04-15
110 //
111 // Copy properties of source drawmethod to target drawmethod.
openbor_copy_drawmethod(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)112 HRESULT openbor_copy_drawmethod(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
113 {
114 #define SELF_NAME       "openbor_copy_drawmethod(void source, void target)"
115 #define ARG_MINIMUM     2   // Minimum required arguments.
116 #define ARG_SOURCE		0
117 #define ARG_TARGET		1
118 
119 	s_drawmethod *source;
120 	s_drawmethod *target;
121 
122 	// Verify arguments.
123 	if (paramCount < ARG_MINIMUM
124 		|| varlist[ARG_SOURCE]->vt != VT_PTR
125 		|| varlist[ARG_TARGET]->vt != VT_PTR)
126 	{
127 		*pretvar = NULL;
128 		goto error_local;
129 	}
130 	else
131 	{
132 		// Populate local vars with arguments.
133 		source = (s_drawmethod *)varlist[ARG_SOURCE]->ptrVal;
134 		target = (s_drawmethod *)varlist[ARG_TARGET]->ptrVal;
135 	}
136 
137 	// Default drawmethod (plainmethod) is a const and therefore cannot
138 	// be mutated. If the author tries it's sure to cause a crash or
139 	// even worse, untracable bugs. We'll send a warning to the log and
140 	// exit function. Note it's perfectly fine to use the default
141 	// drawmethod as a source, and that's probably what will be done
142 	// most of the time anyway.
143 	if (target == &plainmethod)
144 	{
145 		printf("\n Warning: The default drawmethod and its properties are read only: " SELF_NAME "\n");
146 
147 		return S_OK;
148 	}
149 
150 	// Copy values into target drawmethod.
151 	memcpy(target, source, sizeof(*target));
152 
153 	return S_OK;
154 
155 error_local:
156 
157 	printf("\nYou must provide valid source and target drawmethod pointers: " SELF_NAME "\n");
158 	*pretvar = NULL;
159 
160 	return E_FAIL;
161 
162 #undef SELF_NAME
163 #undef ARG_MINIMUM
164 #undef ARG_SOURCE
165 #undef ARG_TARGET
166 }
167 
168 // Caskey, Damon  V.
169 // 2019-04-16
170 //
171 // Allocate a new drawmethod and return the pointer.
openbor_free_drawmethod(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)172 HRESULT openbor_free_drawmethod(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
173 {
174 #define SELF_NAME       "openbor_free_drawmethod(void drawmethod)"
175 #define ARG_MINIMUM     1   // Minimum required arguments.
176 #define ARG_TARGET		0
177 
178 	s_drawmethod *target;
179 
180 	// Verify arguments.
181 	if (paramCount < ARG_MINIMUM
182 		|| varlist[ARG_TARGET]->vt != VT_PTR)
183 	{
184 		*pretvar = NULL;
185 		goto error_local;
186 	}
187 	else
188 	{
189 		// Populate local vars with arguments.
190 		target = (s_drawmethod *)varlist[ARG_TARGET]->ptrVal;
191 	}
192 
193 	// Default drawmethod (plainmethod) is a const and therefore cannot
194 	// be mutated. If the author tries it's sure to cause a crash or
195 	// even worse, untracable bugs. We'll send a warning to the log and
196 	// exit function.
197 	if (target == &plainmethod)
198 	{
199 		printf("\n Warning: The default drawmethod and its properties are read only: " SELF_NAME "\n");
200 
201 		return S_OK;
202 	}
203 
204 	// Free the drawmethod.
205 	free(target);
206 
207 	return S_OK;
208 
209 error_local:
210 
211 	printf("\n You must provide a valid drawmethod pointer: " SELF_NAME "\n");
212 	*pretvar = NULL;
213 
214 	return E_FAIL;
215 
216 #undef SELF_NAME
217 #undef ARG_MINIMUM
218 #undef ARG_TARGET
219 }
220 
221 // Caskey, Damon  V.
222 // 2019-03-28
223 //
224 // Return a drawmethod property. Requires
225 // the pointer from drawmethod property
226 // and a property to access.
openbor_get_drawmethod_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)227 HRESULT openbor_get_drawmethod_property(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
228 {
229 #define SELF_NAME       "openbor_get_drawmethod_property(void drawmethod, char property)"
230 #define ARG_MINIMUM     2   // Minimum required arguments.
231 #define ARG_HANDLE      0   // Handle (pointer to property structure).
232 #define ARG_PROPERTY    1   // Property to access.
233 
234 	s_drawmethod				*handle = NULL;		// Property handle.
235 	e_drawmethod_properties		property = 0;		// Property argument.
236 
237 	// Clear pass by reference argument used to send
238 	// property data back to calling script.     .
239 	ScriptVariant_Clear(*pretvar);
240 
241 	// Verify arguments. There should at least
242 	// be a pointer for the property handle and an integer
243 	// to determine which property constant is accessed.
244 	if (paramCount < ARG_MINIMUM
245 		|| varlist[ARG_HANDLE]->vt != VT_PTR
246 		|| varlist[ARG_PROPERTY]->vt != VT_INTEGER)
247 	{
248 		*pretvar = NULL;
249 		goto error_local;
250 	}
251 	else
252 	{
253 		// Populate local vars for readability.
254 		handle = (s_drawmethod *)varlist[ARG_HANDLE]->ptrVal;
255 		property = (LONG)varlist[ARG_PROPERTY]->lVal;
256 	}
257 
258 	switch (property)
259 	{
260 	case _DRAWMETHOD_ALPHA:
261 
262 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
263 		(*pretvar)->lVal = (LONG)handle->alpha;
264 
265 		break;
266 
267 	case _DRAWMETHOD_BACKGROUND_TRANSPARENCY:
268 
269 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
270 		(*pretvar)->lVal = (LONG)handle->transbg;
271 
272 		break;
273 
274 	case _DRAWMETHOD_CENTER_X:
275 
276 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
277 		(*pretvar)->lVal = (LONG)handle->centerx;
278 
279 		break;
280 
281 	case _DRAWMETHOD_CENTER_Y:
282 
283 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
284 		(*pretvar)->lVal = (LONG)handle->centery;
285 
286 		break;
287 
288 	case _DRAWMETHOD_CHANNEL_BLUE:
289 
290 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
291 		(*pretvar)->lVal = (LONG)handle->channelb;
292 
293 		break;
294 
295 	case _DRAWMETHOD_CHANNEL_GREEN:
296 
297 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
298 		(*pretvar)->lVal = (LONG)handle->channelg;
299 
300 		break;
301 
302 	case _DRAWMETHOD_CHANNEL_RED:
303 
304 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
305 		(*pretvar)->lVal = (LONG)handle->channelr;
306 
307 		break;
308 
309 	case _DRAWMETHOD_CLIP_POSITION_X:
310 
311 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
312 		(*pretvar)->lVal = (LONG)handle->clipx;
313 
314 		break;
315 
316 	case _DRAWMETHOD_CLIP_POSITION_Y:
317 
318 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
319 		(*pretvar)->lVal = (LONG)handle->clipy;
320 
321 		break;
322 
323 	case _DRAWMETHOD_CLIP_SIZE_X:
324 
325 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
326 		(*pretvar)->lVal = (LONG)handle->clipw;
327 
328 		break;
329 
330 	case _DRAWMETHOD_CLIP_SIZE_Y:
331 
332 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
333 		(*pretvar)->lVal = (LONG)handle->cliph;
334 
335 		break;
336 
337 	case _DRAWMETHOD_COLORSET_INDEX:
338 
339 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
340 		(*pretvar)->lVal = (LONG)handle->remap;
341 
342 		break;
343 
344 	case _DRAWMETHOD_COLORSET_TABLE:
345 
346 		ScriptVariant_ChangeType(*pretvar, VT_PTR);
347 		(*pretvar)->ptrVal = (VOID *)(handle->table);
348 
349 		break;
350 
351 	case _DRAWMETHOD_ENABLE:
352 
353 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
354 		(*pretvar)->lVal = (LONG)handle->flag;
355 
356 		break;
357 
358 	case _DRAWMETHOD_FILL_COLOR:
359 
360 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
361 		(*pretvar)->lVal = (LONG)handle->fillcolor;
362 
363 		break;
364 
365 	case _DRAWMETHOD_FLIP_X:
366 
367 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
368 		(*pretvar)->lVal = (LONG)handle->flipx;
369 
370 		break;
371 
372 	case _DRAWMETHOD_FLIP_Y:
373 
374 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
375 		(*pretvar)->lVal = (LONG)handle->flipy;
376 
377 		break;
378 
379 	case _DRAWMETHOD_REPEAT_X:
380 
381 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
382 		(*pretvar)->lVal = (LONG)handle->xrepeat;
383 
384 		break;
385 
386 	case _DRAWMETHOD_REPEAT_Y:
387 
388 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
389 		(*pretvar)->lVal = (LONG)handle->yrepeat;
390 
391 		break;
392 
393 	case _DRAWMETHOD_ROTATE:
394 
395 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
396 		(*pretvar)->lVal = (LONG)handle->rotate;
397 
398 		break;
399 
400 	case _DRAWMETHOD_ROTATE_FLIP:
401 
402 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
403 		(*pretvar)->lVal = (LONG)handle->fliprotate;
404 
405 		break;
406 
407 	case _DRAWMETHOD_SCALE_X:
408 
409 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
410 		(*pretvar)->lVal = (LONG)handle->scalex;
411 
412 		break;
413 
414 	case _DRAWMETHOD_SCALE_Y:
415 
416 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
417 		(*pretvar)->lVal = (LONG)handle->scaley;
418 
419 		break;
420 
421 	case _DRAWMETHOD_SHIFT_X:
422 
423 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
424 		(*pretvar)->lVal = (LONG)handle->shiftx;
425 
426 		break;
427 
428 	case _DRAWMETHOD_SPAN_X:
429 
430 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
431 		(*pretvar)->lVal = (LONG)handle->xspan;
432 
433 		break;
434 
435 	case _DRAWMETHOD_SPAN_Y:
436 
437 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
438 		(*pretvar)->lVal = (LONG)handle->yspan;
439 
440 		break;
441 
442 	case _DRAWMETHOD_TAG:
443 
444 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
445 		(*pretvar)->lVal = (LONG)handle->tag;
446 
447 		break;
448 
449 	case _DRAWMETHOD_TINT_COLOR:
450 
451 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
452 		(*pretvar)->lVal = (LONG)handle->tintcolor;
453 
454 		break;
455 
456 	case _DRAWMETHOD_TINT_MODE:
457 
458 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
459 		(*pretvar)->lVal = (LONG)handle->tintmode;
460 
461 		break;
462 
463 	case _DRAWMETHOD_WATER_MODE:
464 
465 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
466 		(*pretvar)->lVal = (LONG)handle->water.watermode;
467 
468 		break;
469 
470 	case _DRAWMETHOD_WATER_PERSPECTIVE:
471 
472 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
473 		(*pretvar)->lVal = (LONG)handle->water.perspective;
474 
475 		break;
476 
477 	case _DRAWMETHOD_WATER_SIZE_BEGIN:
478 
479 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
480 		(*pretvar)->lVal = (LONG)handle->water.beginsize;
481 
482 		break;
483 
484 	case _DRAWMETHOD_WATER_SIZE_END:
485 
486 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
487 		(*pretvar)->lVal = (LONG)handle->water.endsize;
488 
489 		break;
490 
491 	case _DRAWMETHOD_WATER_WAVE_AMPLITUDE:
492 
493 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
494 		(*pretvar)->lVal = (LONG)handle->water.amplitude;
495 
496 		break;
497 
498 	case _DRAWMETHOD_WATER_WAVE_LENGTH:
499 
500 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
501 		(*pretvar)->lVal = (LONG)handle->water.wavelength;
502 
503 		break;
504 
505 	case _DRAWMETHOD_WATER_WAVE_SPEED:
506 
507 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
508 		(*pretvar)->lVal = (LONG)handle->water.wavespeed;
509 
510 		break;
511 
512 	case _DRAWMETHOD_WATER_WAVE_TIME:
513 
514 		ScriptVariant_ChangeType(*pretvar, VT_INTEGER);
515 		(*pretvar)->lVal = (LONG)handle->water.wavetime;
516 
517 		break;
518 
519 	default:
520 
521 		printf("Unsupported property.\n");
522 		goto error_local;
523 
524 		break;
525 	}
526 
527 	return S_OK;
528 
529 error_local:
530 
531 	printf("\nYou must provide a valid pointer and property name: " SELF_NAME "\n");
532 	*pretvar = NULL;
533 
534 	return E_FAIL;
535 
536 #undef SELF_NAME
537 #undef ARG_MINIMUM
538 #undef ARG_HANDLE
539 #undef ARG_INDEX
540 }
541 
542 // Caskey, Damon  V.
543 // 2019-03-28
544 //
545 // Mutate a drawmethod property. Requires
546 // the pointer from drawmethod property
547 // and a property to access.
openbor_set_drawmethod_property(ScriptVariant ** varlist,ScriptVariant ** pretvar,int paramCount)548 HRESULT openbor_set_drawmethod_property(ScriptVariant **varlist, ScriptVariant **pretvar, int paramCount)
549 {
550 #define SELF_NAME			"set_drawmethod_property(void drawmethod, char property, mixed value)"
551 #define ARG_MINIMUM         3   // Minimum required arguments.
552 #define ARG_HANDLE          0   // Handle (pointer to property structure).
553 #define ARG_PROPERTY        1   // Property to access.
554 #define ARG_VALUE           2   // New value to apply.
555 
556 	s_drawmethod			*handle = NULL;	// Property handle.
557 	e_drawmethod_properties	property = 0;	// Property to access.
558 
559 	// Value carriers to apply on properties after
560 	// taken from argument.
561 	LONG         temp_int;
562 
563 	// Verify incoming arguments. There should at least
564 	// be a pointer for the property handle and an integer
565 	// to determine which property is accessed.
566 	if (paramCount < ARG_MINIMUM
567 		|| varlist[ARG_HANDLE]->vt != VT_PTR
568 		|| varlist[ARG_PROPERTY]->vt != VT_INTEGER)
569 	{
570 		*pretvar = NULL;
571 		goto error_local;
572 	}
573 
574 	// Populate local handle and property vars.
575 	handle = (s_drawmethod *)varlist[ARG_HANDLE]->ptrVal;
576 	property = (LONG)varlist[ARG_PROPERTY]->lVal;
577 
578 	// Default drawmethod (plainmethod) is a const and therefore cannot
579 	// be mutated. If the author tries it's sure to cause a crash or
580 	// even worse, untracable bugs. We'll send a warning to the log and
581 	// exit function.
582 	if (handle == &plainmethod)
583 	{
584 		printf("\n Warning: The default drawmethod and its properties are read only: " SELF_NAME "\n");
585 
586 		return S_OK;
587 	}
588 
589 	// Which property to modify?
590 	switch (property)
591 	{
592 
593 	case _DRAWMETHOD_ALPHA:
594 
595 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
596 		{
597 			handle->alpha = temp_int;
598 		}
599 
600 		break;
601 
602 	case _DRAWMETHOD_BACKGROUND_TRANSPARENCY:
603 
604 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
605 		{
606 			handle->transbg = temp_int;
607 		}
608 
609 		break;
610 
611 	case _DRAWMETHOD_CENTER_X:
612 
613 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
614 		{
615 			handle->centerx = temp_int;
616 		}
617 
618 		break;
619 
620 	case _DRAWMETHOD_CENTER_Y:
621 
622 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
623 		{
624 			handle->centery = temp_int;
625 		}
626 
627 		break;
628 
629 	case _DRAWMETHOD_CHANNEL_BLUE:
630 
631 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
632 		{
633 			handle->channelb = temp_int;
634 		}
635 
636 		break;
637 
638 	case _DRAWMETHOD_CHANNEL_GREEN:
639 
640 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
641 		{
642 			handle->channelg = temp_int;
643 		}
644 
645 		break;
646 
647 	case _DRAWMETHOD_CHANNEL_RED:
648 
649 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
650 		{
651 			handle->channelr = temp_int;
652 		}
653 
654 		break;
655 
656 	case _DRAWMETHOD_CLIP_POSITION_X:
657 
658 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
659 		{
660 			handle->clipx = temp_int;
661 		}
662 
663 		break;
664 
665 	case _DRAWMETHOD_CLIP_POSITION_Y:
666 
667 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
668 		{
669 			handle->clipy = temp_int;
670 		}
671 
672 		break;
673 
674 	case _DRAWMETHOD_CLIP_SIZE_X:
675 
676 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
677 		{
678 			handle->clipw = temp_int;
679 		}
680 
681 		break;
682 
683 	case _DRAWMETHOD_CLIP_SIZE_Y:
684 
685 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
686 		{
687 			handle->cliph = temp_int;
688 		}
689 
690 		break;
691 
692 	case _DRAWMETHOD_COLORSET_INDEX:
693 
694 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
695 		{
696 			handle->remap = temp_int;
697 		}
698 
699 		break;
700 
701 	case _DRAWMETHOD_COLORSET_TABLE:
702 
703 		handle->table = (VOID *)varlist[ARG_VALUE]->ptrVal;
704 
705 		break;
706 
707 	case _DRAWMETHOD_ENABLE:
708 
709 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
710 		{
711 			handle->flag = temp_int;
712 		}
713 
714 		break;
715 
716 	case _DRAWMETHOD_FILL_COLOR:
717 
718 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
719 		{
720 			handle->fillcolor = temp_int;
721 		}
722 
723 		break;
724 
725 	case _DRAWMETHOD_FLIP_X:
726 
727 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
728 		{
729 			handle->flipx = temp_int;
730 		}
731 
732 		break;
733 
734 	case _DRAWMETHOD_FLIP_Y:
735 
736 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
737 		{
738 			handle->flipy = temp_int;
739 		}
740 
741 		break;
742 
743 	case _DRAWMETHOD_REPEAT_X:
744 
745 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
746 		{
747 			handle->xrepeat = temp_int;
748 		}
749 
750 		break;
751 
752 	case _DRAWMETHOD_REPEAT_Y:
753 
754 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
755 		{
756 			handle->yrepeat = temp_int;
757 		}
758 
759 		break;
760 
761 	case _DRAWMETHOD_ROTATE:
762 
763 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
764 		{
765 			handle->rotate = temp_int;
766 		}
767 
768 		break;
769 
770 	case _DRAWMETHOD_ROTATE_FLIP:
771 
772 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
773 		{
774 			handle->fliprotate = temp_int;
775 		}
776 
777 		break;
778 
779 	case _DRAWMETHOD_SCALE_X:
780 
781 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
782 		{
783 			handle->scalex = temp_int;
784 		}
785 
786 		break;
787 
788 	case _DRAWMETHOD_SCALE_Y:
789 
790 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
791 		{
792 			handle->scaley = temp_int;
793 		}
794 
795 		break;
796 
797 	case _DRAWMETHOD_SHIFT_X:
798 
799 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
800 		{
801 			handle->shiftx = temp_int;
802 		}
803 
804 		break;
805 
806 	case _DRAWMETHOD_SPAN_X:
807 
808 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
809 		{
810 			handle->xspan = temp_int;
811 		}
812 
813 		break;
814 
815 	case _DRAWMETHOD_SPAN_Y:
816 
817 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
818 		{
819 			handle->yspan = temp_int;
820 		}
821 
822 		break;
823 
824 	case _DRAWMETHOD_TAG:
825 
826 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
827 		{
828 			handle->tag = temp_int;
829 		}
830 
831 		break;
832 
833 	case _DRAWMETHOD_TINT_COLOR:
834 
835 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
836 		{
837 			handle->tintcolor = temp_int;
838 		}
839 
840 		break;
841 
842 	case _DRAWMETHOD_TINT_MODE:
843 
844 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
845 		{
846 			handle->tintmode = temp_int;
847 		}
848 
849 		break;
850 
851 	case _DRAWMETHOD_WATER_MODE:
852 
853 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
854 		{
855 			handle->water.watermode = temp_int;
856 		}
857 
858 		break;
859 
860 	case _DRAWMETHOD_WATER_PERSPECTIVE:
861 
862 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
863 		{
864 			handle->water.perspective = temp_int;
865 		}
866 
867 	case _DRAWMETHOD_WATER_SIZE_BEGIN:
868 
869 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
870 		{
871 			handle->water.beginsize = temp_int;
872 		}
873 
874 	case _DRAWMETHOD_WATER_SIZE_END:
875 
876 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
877 		{
878 			handle->water.endsize = temp_int;
879 		}
880 
881 		break;
882 
883 	case _DRAWMETHOD_WATER_WAVE_AMPLITUDE:
884 
885 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
886 		{
887 			handle->water.amplitude = temp_int;
888 		}
889 
890 		break;
891 
892 	case _DRAWMETHOD_WATER_WAVE_LENGTH:
893 
894 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
895 		{
896 			handle->water.wavelength = temp_int;
897 		}
898 
899 		break;
900 
901 	case _DRAWMETHOD_WATER_WAVE_SPEED:
902 
903 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
904 		{
905 			handle->water.wavespeed = temp_int;
906 		}
907 
908 		break;
909 
910 	case _DRAWMETHOD_WATER_WAVE_TIME:
911 
912 		if (SUCCEEDED(ScriptVariant_IntegerValue(varlist[ARG_VALUE], &temp_int)))
913 		{
914 			handle->water.wavetime = temp_int;
915 		}
916 
917 		break;
918 
919 	default:
920 
921 		printf("Unsupported property.\n");
922 		goto error_local;
923 
924 		break;
925 	}
926 
927 	return S_OK;
928 
929 	// Error trapping.
930 error_local:
931 
932 	printf("\nYou must provide a valid pointer, property name, and new value: " SELF_NAME "\n");
933 
934 	return E_FAIL;
935 
936 #undef SELF_NAME
937 #undef ARG_MINIMUM
938 #undef ARG_HANDLE
939 #undef ARG_PROPERTY
940 #undef ARG_VALUE
941 }