Cube  Diff

Differences From Artifact [73836e692f]:

To Artifact [ae7e6c7975]:


167
168
169
170
171
172
173
174

175
176
177
178
179
180
181

182
183
184
185
186

187
188
189
190
191
192
193
194
195
196
197
198
199
200


201
202
203
204
205
206
207
void
calclight()
{
	loop(x, ssize) loop(y, ssize)
	{
		sqr *s = S(x, y);
		s->r = s->g = s->b = 10;
	};


	loopv(ents)
	{
		entity &e = ents[i];
		if (e.type == LIGHT)
			calclightsource(e);
	};


	block b = {1, 1, ssize - 2, ssize - 2};
	postlightarea(b);
	setvar("fullbright", 0);
};


VARP(dynlight, 0, 16, 32);

vector<block *> dlights;

void
cleardlights()
{
	while (!dlights.empty()) {
		block *backup = dlights.pop();
		blockpaste(*backup);
		free(backup);
	};
};



void
dodynlight(vec &vold, vec &v, int reach, int strength, dynent *owner)
{
	if (!reach)
		reach = dynlight;
	if (owner->monsterstate)







<
>






<
>



|
<
>












<
<
>
>







167
168
169
170
171
172
173

174
175
176
177
178
179
180

181
182
183
184
185

186
187
188
189
190
191
192
193
194
195
196
197
198


199
200
201
202
203
204
205
206
207
void
calclight()
{
	loop(x, ssize) loop(y, ssize)
	{
		sqr *s = S(x, y);
		s->r = s->g = s->b = 10;

	}

	loopv(ents)
	{
		entity &e = ents[i];
		if (e.type == LIGHT)
			calclightsource(e);

	}

	block b = {1, 1, ssize - 2, ssize - 2};
	postlightarea(b);
	setvar(@"fullbright", 0);

}

VARP(dynlight, 0, 16, 32);

vector<block *> dlights;

void
cleardlights()
{
	while (!dlights.empty()) {
		block *backup = dlights.pop();
		blockpaste(*backup);
		free(backup);


	}
}

void
dodynlight(vec &vold, vec &v, int reach, int strength, dynent *owner)
{
	if (!reach)
		reach = dynlight;
	if (owner->monsterstate)
226
227
228
229
230
231
232
233

234
235
236
237
238
239
240
241
242
243
244
245
246
247

248
249
250
251
252
253
254
255
256
257


	dlights.add(blockcopy(b)); // backup area before rendering in dynlight

	persistent_entity l = {(short)v.x, (short)v.y, (short)v.z, (short)reach,
	    LIGHT, (uchar)strength, 0, 0};
	calclightsource(l);
	postlightarea(b);
};


// utility functions also used by editing code

block *
blockcopy(block &s)
{
	block *b = (block *)alloc(sizeof(block) + s.xs * s.ys * sizeof(sqr));
	*b = s;
	sqr *q = (sqr *)(b + 1);
	for (int x = s.x; x < s.xs + s.x; x++)
		for (int y = s.y; y < s.ys + s.y; y++)
			*q++ = *S(x, y);
	return b;
};


void
blockpaste(block &b)
{
	sqr *q = (sqr *)((&b) + 1);
	for (int x = b.x; x < b.xs + b.x; x++)
		for (int y = b.y; y < b.ys + b.y; y++)
			*S(x, y) = *q++;
	remipmore(b);
};








<
>













<
>









<
>
226
227
228
229
230
231
232

233
234
235
236
237
238
239
240
241
242
243
244
245
246

247
248
249
250
251
252
253
254
255
256

257

	dlights.add(blockcopy(b)); // backup area before rendering in dynlight

	persistent_entity l = {(short)v.x, (short)v.y, (short)v.z, (short)reach,
	    LIGHT, (uchar)strength, 0, 0};
	calclightsource(l);
	postlightarea(b);

}

// utility functions also used by editing code

block *
blockcopy(block &s)
{
	block *b = (block *)alloc(sizeof(block) + s.xs * s.ys * sizeof(sqr));
	*b = s;
	sqr *q = (sqr *)(b + 1);
	for (int x = s.x; x < s.xs + s.x; x++)
		for (int y = s.y; y < s.ys + s.y; y++)
			*q++ = *S(x, y);
	return b;

}

void
blockpaste(block &b)
{
	sqr *q = (sqr *)((&b) + 1);
	for (int x = b.x; x < b.xs + b.x; x++)
		for (int y = b.y; y < b.ys + b.y; y++)
			*S(x, y) = *q++;
	remipmore(b);

}