Changeset - r5617:94e7517dc4e8
[Not reviewed]
master
0 3 0
maedhros - 17 years ago 2007-01-12 11:20:34
maedhros@openttd.org
(svn r8075) -Feature: Add support for variable 7E - subroutines. (peter1138)
3 files changed with 18 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -1648,7 +1648,12 @@ static void NewSpriteGroup(byte *buf, in
 
				/* The first var adjust doesn't have an operation specified, so we set it to add. */
 
				adjust->operation = group->g.determ.num_adjusts == 1 ? DSGA_OP_ADD : (DeterministicSpriteGroupAdjustOperation)grf_load_byte(&buf);
 
				adjust->variable  = grf_load_byte(&buf);
 
				adjust->parameter = IS_BYTE_INSIDE(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0;
 
				if (adjust->variable == 0x7E) {
 
					/* Link subroutine group */
 
					adjust->subroutine = GetGroupFromGroupID(setid, type, grf_load_byte(&buf));
 
				} else {
 
					adjust->parameter = IS_BYTE_INSIDE(adjust->variable, 0x60, 0x80) ? grf_load_byte(&buf) : 0;
 
				}
 

	
 
				varadjust = grf_load_byte(&buf);
 
				adjust->shift_num = GB(varadjust, 0, 5);
src/newgrf_spritegroup.cpp
Show inline comments
 
@@ -5,6 +5,7 @@
 
#include "variables.h"
 
#include "macros.h"
 
#include "oldpool.h"
 
#include "newgrf_callbacks.h"
 
#include "newgrf_spritegroup.h"
 
#include "date.h"
 

	
 
@@ -142,7 +143,16 @@ static inline const SpriteGroup *Resolve
 

	
 
		/* Try to get the variable. We shall assume it is available, unless told otherwise. */
 
		bool available = true;
 
		value = GetVariable(object, adjust->variable, adjust->parameter, &available);
 
		if (adjust->variable == 0x7E) {
 
			const SpriteGroup *subgroup = Resolve(adjust->subroutine, object);
 
			if (subgroup == NULL || subgroup->type != SGT_CALLBACK) {
 
				value = CALLBACK_FAILED;
 
			} else {
 
				value = subgroup->g.callback.result;
 
			}
 
		} else {
 
			value = GetVariable(object, adjust->variable, adjust->parameter, &available);
 
		}
 

	
 
		if (!available) {
 
			/* Unsupported property: skip further processing and return either
src/newgrf_spritegroup.h
Show inline comments
 
@@ -69,6 +69,7 @@ typedef struct DeterministicSpriteGroupA
 
	uint32 and_mask;
 
	uint32 add_val;
 
	uint32 divmod_val;
 
	const SpriteGroup *subroutine;
 
} DeterministicSpriteGroupAdjust;
 

	
 

	
0 comments (0 inline, 0 general)