-
Notifications
You must be signed in to change notification settings - Fork 7
/
laundry.c
94 lines (84 loc) · 2.42 KB
/
laundry.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* IceBreaker
* Copyright (c) 2000-2020 Matthew Miller <[email protected]>
*
* <http://www.mattdm.org/icebreaker/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <SDL.h>
#include <stdlib.h>
#include "icebreaker.h"
#include "globals.h"
#include "laundry.h"
#include "options.h"
#include "fullscreen.h"
static SDL_Rect laundrylist[MAXDIRTY];
static int laundrycount;
void initlaundry()
{
laundrycount=0;
}
void soil(SDL_Rect r)
{ // makes stuff dirty, of course.
if (laundrycount<MAXDIRTY) // it's good to have this check here, but
{ // since this is the most-used function in
// the whole program, it might be worth removing
// for production builds...
laundrylist[laundrycount] = r;
laundrycount++;
}
else
{
// fix -- we ought to at least fail gracefully.
// (clean whole screen, laundrylist)
// might be worth dynamically calculating the point at which
// updating everything is more efficient than updating many
// rects.
fprintf(stderr, "Too much dirty laundry!\n");
exit(1);
}
}
void clean()
{
int i;
if (gameflags.isfullscreen)
{
for( i = 0; i < laundrycount; i++)
{ // fix -- sucks to have to do a loop here, but not
// easy to avoid.
laundrylist[i].x += (FULLWIDTH - WIDTH) / 2;
laundrylist[i].y += FULLTOPMARGIN;
}
SDL_UpdateRects(fullscreen, laundrycount, laundrylist);
}
else
{
SDL_UpdateRects(screen, laundrycount, laundrylist);
}
laundrycount=0;
}
void updateall()
{
// FIX -- anything that needs to call this should be fixed to
// use the laundry list properly. then we can remove this
// function completely.
if (gameflags.isfullscreen)
SDL_UpdateRect(fullscreen,0,0,0,0);
else
SDL_UpdateRect(screen,0,0,0,0);
laundrycount=0;
}