Skip to content

Commit

Permalink
Replacing some tabs with spaces.
Browse files Browse the repository at this point in the history
Added Todd Stokes' WIP export function to the Animation Viewer. Many thanks, keep up the good work!
Fix: Let the tired icon emerge at its own decided threshold even if the hospital's policy for going to the staff room is set higher.
Added new strings to the Swedish language.
+ Some miscellaneous refactoring.
  • Loading branch information
Lego3 committed Sep 4, 2011
1 parent b43c63f commit 05ac04b
Show file tree
Hide file tree
Showing 25 changed files with 633 additions and 221 deletions.
2 changes: 1 addition & 1 deletion AnimView/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ SOFTWARE.

class ThemeHospitalAnimViewApp : public wxApp
{
virtual bool OnInit();
virtual bool OnInit();
};

DECLARE_APP(ThemeHospitalAnimViewApp)
301 changes: 301 additions & 0 deletions AnimView/frmMain.cpp

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions AnimView/frmMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ SOFTWARE.
#include <wx/timer.h>
#include <wx/listbox.h>
#include <wx/dcclient.h>
#include <wx/txtstrm.h>
#include "th.h"
//#include <vector>

class frmMain : public wxFrame
{
Expand Down Expand Up @@ -59,15 +61,21 @@ class frmMain : public wxFrame
ID_GHOST_3,
ID_LOAD,
ID_BROWSE,
ID_EXPORT,
ID_DRAW_MOOD,
ID_DRAW_COORDINATES,
ID_LAYER_CHECKS, // Must be last ID
};

void load();
void export_png();
void exportSpritesPage(bool bComplex, wxString sPath, wxString sFilename, wxString spPath=L"", wxString sPalette=L"MPALETTE.DAT");
//std::vector<_sprite_t> m_vSprites;

protected:
void _onLoad(wxCommandEvent& evt);
void _onBrowse(wxCommandEvent& evt);
void _onExport(wxCommandEvent& evt);
void _onFirstAnim(wxCommandEvent& evt);
void _onPrevAnim(wxCommandEvent& evt);
void _onNextAnim(wxCommandEvent& evt);
Expand Down
4 changes: 2 additions & 2 deletions AnimView/frmSprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void frmSprites::_onBrowseTable(wxCommandEvent& WXUNUSED(evt))
{
m_txtTable->SetValue(::wxFileSelector(L"Select location of Font00V.tab (DATA)",
m_txtTable->GetValue(),L"Font00V.tab",L"tab",L"Tab files (*.tab)|*.tab"
,0, this));
,0, this));
}
void frmSprites::_onBrowseData(wxCommandEvent& WXUNUSED(evt))
{
Expand All @@ -192,5 +192,5 @@ void frmSprites::_onBrowseData(wxCommandEvent& WXUNUSED(evt))
void frmSprites::_onBrowsePalette(wxCommandEvent& WXUNUSED(evt))
{
m_txtPalette->SetValue(::wxFileSelector(L"Select location of MPalette.dat (QDATA)",
m_txtPalette->GetValue(),L"MPalette.dat",L"dat",L"Dat files (*.dat)|*.dat", 0, this));
m_txtPalette->GetValue(),L"MPalette.dat",L"dat",L"Dat or Pal files (*.dat, *.pal)|*.dat;*.pal", 0, this));
}
12 changes: 6 additions & 6 deletions AnimView/frmSprites.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class frmSprites : public wxFrame
enum
{
ID_LOAD = wxID_HIGHEST + 1,
ID_BROWSE_TABLE,
ID_BROWSE_DATA,
ID_BROWSE_PALETTE,
ID_BROWSE_TABLE,
ID_BROWSE_DATA,
ID_BROWSE_PALETTE,
ID_LOAD_COMPLEX,
ID_NEXT,
};
Expand All @@ -60,9 +60,9 @@ class frmSprites : public wxFrame
void _onLoad(wxCommandEvent& evt);
void _onLoadComplex(wxCommandEvent& evt);
void _onPanelPaint(wxPaintEvent& evt);
void _onBrowseData(wxCommandEvent& evt);
void _onBrowsePalette(wxCommandEvent& evt);
void _onBrowseTable(wxCommandEvent& evt);
void _onBrowseData(wxCommandEvent& evt);
void _onBrowsePalette(wxCommandEvent& evt);
void _onBrowseTable(wxCommandEvent& evt);

std::vector<_sprite_t> m_vSprites;
THAnimations m_oAnims;
Expand Down
146 changes: 73 additions & 73 deletions AnimView/rnc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ static const unsigned short rnc_crc_table[256] = {

struct bit_stream
{
unsigned long bitbuf; /* holds between 16 and 32 bits */
int bitcount; /* how many bits does bitbuf hold? */
unsigned long bitbuf; /* holds between 16 and 32 bits */
int bitcount; /* how many bits does bitbuf hold? */
};

struct huf_table
{
int num; /* number of nodes in the tree */
struct
int num; /* number of nodes in the tree */
struct
{
unsigned long code;
int codelen;
int value;
} table[32];
unsigned long code;
int codelen;
int value;
} table[32];
};

/*
Expand All @@ -80,8 +80,8 @@ static long rnc_crc(const unsigned char* data, long len)

while(len--)
{
val ^= *data++;
val = (val >> 8) ^ rnc_crc_table[val & 0xFF];
val ^= *data++;
val = (val >> 8) ^ rnc_crc_table[val & 0xFF];
}

return val;
Expand Down Expand Up @@ -144,14 +144,14 @@ static unsigned long mirror (unsigned long x, int n)
unsigned long top = 1 << (n-1), bottom = 1;
while (top > bottom)
{
unsigned long mask = top | bottom;
unsigned long masked = x & mask;
if (masked != 0 && masked != mask)
unsigned long mask = top | bottom;
unsigned long masked = x & mask;
if (masked != 0 && masked != mask)
{
x ^= mask;
x ^= mask;
}
top >>= 1;
bottom <<= 1;
top >>= 1;
bottom <<= 1;
}
return x;
}
Expand Down Expand Up @@ -196,9 +196,9 @@ static void bit_advance (bit_stream *bs, int n, const unsigned char **p)
bs->bitcount -= n;
if (bs->bitcount < 16)
{
(*p) += 2;
bs->bitbuf |= (lword(*p)<<bs->bitcount);
bs->bitcount += 16;
(*p) += 2;
bs->bitbuf |= (lword(*p)<<bs->bitcount);
bs->bitcount += 16;
}
}

Expand All @@ -220,41 +220,41 @@ static void read_huftable(huf_table *h, bit_stream *bs, const unsigned char **p)
int i, j, k, num;
int leaflen[32];
int leafmax;
unsigned long codeb; /* big-endian form of code */
unsigned long codeb; /* big-endian form of code */

num = bit_read(bs, 0x1F, 5, p);

if(num == 0)
{
return;
return;
}

leafmax = 1;
for(i = 0; i < num; i++)
{
leaflen[i] = bit_read(bs, 0x0F, 4, p);
if (leafmax < leaflen[i])
leaflen[i] = bit_read(bs, 0x0F, 4, p);
if (leafmax < leaflen[i])
{
leafmax = leaflen[i];
leafmax = leaflen[i];
}
}

codeb = 0L;
k = 0;
for(i = 1; i <= leafmax; i++)
{
for(j = 0; j < num; j++)
for(j = 0; j < num; j++)
{
if(leaflen[j] == i)
if(leaflen[j] == i)
{
h->table[k].code = mirror(codeb, i);
h->table[k].codelen = i;
h->table[k].value = j;
codeb++;
k++;
}
h->table[k].code = mirror(codeb, i);
h->table[k].codelen = i;
h->table[k].value = j;
codeb++;
k++;
}
}
codeb <<= 1;
codeb <<= 1;
}
h->num = k;
}
Expand All @@ -269,24 +269,24 @@ static unsigned long huf_read(huf_table *h, bit_stream *bs, const unsigned char

for (i = 0; i < h->num; i++)
{
unsigned long mask = (1 << h->table[i].codelen) - 1;
if(bit_peek(bs, mask) == h->table[i].code)
unsigned long mask = (1 << h->table[i].codelen) - 1;
if(bit_peek(bs, mask) == h->table[i].code)
{
break;
break;
}
}
if(i == h->num)
{
return -1;
return -1;
}
bit_advance(bs, h->table[i].codelen, p);

val = h->table[i].value;

if (val >= 2)
{
val = 1 << (val-1);
val |= bit_read(bs, val-1, h->table[i].value - 1, p);
val = 1 << (val-1);
val |= bit_read(bs, val-1, h->table[i].value - 1, p);
}
return val;
}
Expand All @@ -302,21 +302,21 @@ static int rnc_unpack(const unsigned char* input, unsigned char* output)
unsigned out_crc;
if(blong(input) != RNC_SIGNATURE)
{
return RNC_FILE_IS_NOT_RNC;
return RNC_FILE_IS_NOT_RNC;
}
ret_len = blong(input + 4);
outputend = output + ret_len;
inputend = input + 18 + blong(input + 8);

input += 18; /* skip header */
input += 18; /* skip header */

/*
* Check the packed-data CRC. Also save the unpacked-data CRC
* for later.
*/
if(rnc_crc(input, inputend-input) != bword(input - 4))
{
return RNC_PACKED_CRC_ERROR;
return RNC_PACKED_CRC_ERROR;
}
out_crc = bword(input - 6);

Expand All @@ -328,62 +328,62 @@ static int rnc_unpack(const unsigned char* input, unsigned char* output)
*/
while (output < outputend)
{
read_huftable(&raw, &bs, &input);
read_huftable(&dist, &bs, &input);
read_huftable(&len, &bs, &input);
ch_count = bit_read(&bs, 0xFFFF, 16, &input);
read_huftable(&raw, &bs, &input);
read_huftable(&dist, &bs, &input);
read_huftable(&len, &bs, &input);
ch_count = bit_read(&bs, 0xFFFF, 16, &input);

while(true)
while(true)
{
long length, posn;
long length, posn;

length = huf_read(&raw, &bs, &input);
if(length == -1)
length = huf_read(&raw, &bs, &input);
if(length == -1)
{
return RNC_HUF_DECODE_ERROR;
return RNC_HUF_DECODE_ERROR;
}
if(length)
if(length)
{
while(length--)
*output++ = *input++;
bitread_fix(&bs, &input);
}
if(--ch_count <= 0)
while(length--)
*output++ = *input++;
bitread_fix(&bs, &input);
}
if(--ch_count <= 0)
{
break;
break;
}

posn = huf_read(&dist, &bs, &input);
if(posn == -1)
posn = huf_read(&dist, &bs, &input);
if(posn == -1)
{
return RNC_HUF_DECODE_ERROR;
return RNC_HUF_DECODE_ERROR;
}
length = huf_read(&len, &bs, &input);
if(length == -1)
length = huf_read(&len, &bs, &input);
if(length == -1)
{
return RNC_HUF_DECODE_ERROR;
return RNC_HUF_DECODE_ERROR;
}
posn += 1;
length += 2;
while(length--)
posn += 1;
length += 2;
while(length--)
{
*output = output[-posn];
output++;
}
}
*output = output[-posn];
output++;
}
}
}

if(outputend != output)
{
return RNC_FILE_SIZE_MISMATCH;
return RNC_FILE_SIZE_MISMATCH;
}

/*
* Check the unpacked-data CRC.
*/
if(rnc_crc(outputend - ret_len, ret_len) != out_crc)
{
return RNC_UNPACKED_CRC_ERROR;
return RNC_UNPACKED_CRC_ERROR;
}

return RNC_OK;
Expand Down
Loading

0 comments on commit 05ac04b

Please sign in to comment.