mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Merge branch 'master' of https://github.com/TerryCavanagh/VVVVVV
This commit is contained in:
commit
01d2cdd42a
23 changed files with 431 additions and 480 deletions
|
@ -14,6 +14,7 @@ Contributors
|
||||||
* Elijah Stone (@moon-chilled)
|
* Elijah Stone (@moon-chilled)
|
||||||
* Elliott Saltar (@eboyblue3)
|
* Elliott Saltar (@eboyblue3)
|
||||||
* Emmanuel Vadot (@evadot)
|
* Emmanuel Vadot (@evadot)
|
||||||
|
* fraZ0R (@f-raZ0R)
|
||||||
* Fredrik Ljungdahl (@FredrIQ)
|
* Fredrik Ljungdahl (@FredrIQ)
|
||||||
* Jules de Sartiges (@strikersh)
|
* Jules de Sartiges (@strikersh)
|
||||||
* Keith Stellyes (@keithstellyes)
|
* Keith Stellyes (@keithstellyes)
|
||||||
|
|
19
desktop_version/src/Alloc.h
Normal file
19
desktop_version/src/Alloc.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef ALLOCGAME_H
|
||||||
|
#define ALLOCGAME_H
|
||||||
|
|
||||||
|
/* TODO: VVV_malloc, VVV_realloc, etc. */
|
||||||
|
|
||||||
|
#define VVV_freefunc(func, obj) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
if (obj != NULL) \
|
||||||
|
{ \
|
||||||
|
func(obj); \
|
||||||
|
obj = NULL; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
#define VVV_free(obj) VVV_freefunc(SDL_free, obj)
|
||||||
|
|
||||||
|
#endif /* ALLOCGAME_H */
|
|
@ -5,6 +5,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "Exit.h"
|
#include "Exit.h"
|
||||||
#include "FileSystemUtils.h"
|
#include "FileSystemUtils.h"
|
||||||
#include "UtilityClass.h"
|
#include "UtilityClass.h"
|
||||||
|
@ -91,7 +92,7 @@ void binaryBlob::clear(void)
|
||||||
{
|
{
|
||||||
if (m_memblocks[i] != NULL)
|
if (m_memblocks[i] != NULL)
|
||||||
{
|
{
|
||||||
SDL_free(m_memblocks[i]);
|
VVV_free(m_memblocks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SDL_zeroa(m_memblocks);
|
SDL_zeroa(m_memblocks);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
extern "C" char* HELP_number_words(int _t)
|
extern "C" char* HELP_number_words(int _t)
|
||||||
{
|
{
|
||||||
/* C wrapper for UtilityClass::number_words.
|
/* C wrapper for UtilityClass::number_words.
|
||||||
* Caller must SDL_free. */
|
* Caller must VVV_free. */
|
||||||
|
|
||||||
std::string str = help.number_words(_t);
|
std::string str = help.number_words(_t);
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ static const char* githubfriends[] = {
|
||||||
"Elijah Stone",
|
"Elijah Stone",
|
||||||
"Elliott Saltar",
|
"Elliott Saltar",
|
||||||
"Emmanuel Vadot",
|
"Emmanuel Vadot",
|
||||||
|
"fraZ0R",
|
||||||
"Fredrik Ljungdahl",
|
"Fredrik Ljungdahl",
|
||||||
"Keith Stellyes",
|
"Keith Stellyes",
|
||||||
"KyoZM",
|
"KyoZM",
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
#include <utf8/unchecked.h>
|
#include <utf8/unchecked.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "Editor.h"
|
#include "Editor.h"
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
|
@ -267,7 +268,7 @@ bool customlevelclass::getLevelMetaDataAndPlaytestArgs(const std::string& _path,
|
||||||
|
|
||||||
std::string buf((char*) uMem);
|
std::string buf((char*) uMem);
|
||||||
|
|
||||||
FILESYSTEM_freeMemory(&uMem);
|
VVV_free(uMem);
|
||||||
|
|
||||||
if (find_metadata(buf) == "")
|
if (find_metadata(buf) == "")
|
||||||
{
|
{
|
||||||
|
@ -1483,116 +1484,92 @@ bool customlevelclass::save(const std::string& _path)
|
||||||
|
|
||||||
void customlevelclass::generatecustomminimap(void)
|
void customlevelclass::generatecustomminimap(void)
|
||||||
{
|
{
|
||||||
map.customwidth=mapwidth;
|
map.customzoom = 1;
|
||||||
map.customheight=mapheight;
|
if (mapwidth <= 10 && mapheight <= 10)
|
||||||
|
|
||||||
map.customzoom=1;
|
|
||||||
if(map.customwidth<=10 && map.customheight<=10) map.customzoom=2;
|
|
||||||
if(map.customwidth<=5 && map.customheight<=5) map.customzoom=4;
|
|
||||||
|
|
||||||
//Set minimap offsets
|
|
||||||
if(map.customzoom==4)
|
|
||||||
{
|
{
|
||||||
map.custommmxoff=24*(5-map.customwidth);
|
map.customzoom = 2;
|
||||||
map.custommmxsize=240-(map.custommmxoff*2);
|
|
||||||
|
|
||||||
map.custommmyoff=18*(5-map.customheight);
|
|
||||||
map.custommmysize=180-(map.custommmyoff*2);
|
|
||||||
}
|
}
|
||||||
else if(map.customzoom==2)
|
if (mapwidth <= 5 && mapheight <= 5)
|
||||||
{
|
{
|
||||||
map.custommmxoff=12*(10-map.customwidth);
|
map.customzoom = 4;
|
||||||
map.custommmxsize=240-(map.custommmxoff*2);
|
|
||||||
|
|
||||||
map.custommmyoff=9*(10-map.customheight);
|
|
||||||
map.custommmysize=180-(map.custommmyoff*2);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Set minimap offsets
|
||||||
|
switch (map.customzoom)
|
||||||
{
|
{
|
||||||
map.custommmxoff=6*(20-map.customwidth);
|
case 4:
|
||||||
map.custommmxsize=240-(map.custommmxoff*2);
|
map.custommmxoff = 24 * (5 - mapwidth);
|
||||||
|
map.custommmyoff = 18 * (5 - mapheight);
|
||||||
map.custommmyoff=int(4.5*(20-map.customheight));
|
break;
|
||||||
map.custommmysize=180-(map.custommmyoff*2);
|
case 2:
|
||||||
|
map.custommmxoff = 12 * (10 - mapwidth);
|
||||||
|
map.custommmyoff = 9 * (10 - mapheight);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
map.custommmxoff = 6 * (20 - mapwidth);
|
||||||
|
map.custommmyoff = int(4.5 * (20 - mapheight));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
map.custommmxsize = 240 - (map.custommmxoff * 2);
|
||||||
|
map.custommmysize = 180 - (map.custommmyoff * 2);
|
||||||
|
|
||||||
FillRect(graphics.images[12], graphics.getRGB(0, 0, 0));
|
FillRect(graphics.images[12], graphics.getRGB(0, 0, 0));
|
||||||
|
|
||||||
int tm=0;
|
// Scan over the map size
|
||||||
int temp=0;
|
for (int j2 = 0; j2 < mapheight; j2++)
|
||||||
//Scan over the map size
|
|
||||||
if(mapheight<=5 && mapwidth<=5)
|
|
||||||
{
|
{
|
||||||
//4x map
|
for (int i2 = 0; i2 < mapwidth; i2++)
|
||||||
for(int j2=0; j2<mapheight; j2++)
|
|
||||||
{
|
{
|
||||||
for(int i2=0; i2<mapwidth; i2++)
|
int tm;
|
||||||
|
if (getroomprop(i2, j2)->tileset == 1)
|
||||||
{
|
{
|
||||||
//Ok, now scan over each square
|
tm = 96;
|
||||||
tm=196;
|
|
||||||
if(getroomprop(i2, j2)->tileset==1) tm=96;
|
|
||||||
|
|
||||||
for(int j=0; j<36; j++)
|
|
||||||
{
|
|
||||||
for(int i=0; i<48; i++)
|
|
||||||
{
|
|
||||||
temp=absfree(int(i*0.83) + (i2*40),int(j*0.83)+(j2*30));
|
|
||||||
if(temp>=1)
|
|
||||||
{
|
|
||||||
//Fill in this pixel
|
|
||||||
FillRect(graphics.images[12], (i2*48)+i, (j2*36)+j, 1, 1, graphics.getRGB(tm, tm, tm));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(mapheight<=10 && mapwidth<=10)
|
|
||||||
{
|
|
||||||
//2x map
|
|
||||||
for(int j2=0; j2<mapheight; j2++)
|
|
||||||
{
|
|
||||||
for(int i2=0; i2<mapwidth; i2++)
|
|
||||||
{
|
|
||||||
//Ok, now scan over each square
|
|
||||||
tm=196;
|
|
||||||
if(getroomprop(i2, j2)->tileset==1) tm=96;
|
|
||||||
|
|
||||||
for(int j=0; j<18; j++)
|
|
||||||
{
|
|
||||||
for(int i=0; i<24; i++)
|
|
||||||
{
|
|
||||||
temp=absfree(int(i*1.6) + (i2*40),int(j*1.6)+(j2*30));
|
|
||||||
if(temp>=1)
|
|
||||||
{
|
|
||||||
//Fill in this pixel
|
|
||||||
FillRect(graphics.images[12], (i2*24)+i, (j2*18)+j, 1, 1, graphics.getRGB(tm, tm, tm));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(int j2=0; j2<mapheight; j2++)
|
tm = 196;
|
||||||
{
|
|
||||||
for(int i2=0; i2<mapwidth; i2++)
|
|
||||||
{
|
|
||||||
//Ok, now scan over each square
|
|
||||||
tm=196;
|
|
||||||
if(getroomprop(i2, j2)->tileset==1) tm=96;
|
|
||||||
|
|
||||||
for(int j=0; j<9; j++)
|
|
||||||
{
|
|
||||||
for(int i=0; i<12; i++)
|
|
||||||
{
|
|
||||||
temp=absfree(3+(i*3) + (i2*40),(j*3)+(j2*30));
|
|
||||||
if(temp>=1)
|
|
||||||
{
|
|
||||||
//Fill in this pixel
|
|
||||||
FillRect(graphics.images[12], (i2*12)+i, (j2*9)+j, 1, 1, graphics.getRGB(tm, tm, tm));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ok, now scan over each square
|
||||||
|
for (int j = 0; j < 9 * map.customzoom; j++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 12 * map.customzoom; i++)
|
||||||
|
{
|
||||||
|
int tile;
|
||||||
|
switch (map.customzoom)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
tile = absfree(
|
||||||
|
int(i * 0.83) + (i2 * 40),
|
||||||
|
int(j * 0.83) + (j2 * 30)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
tile = absfree(
|
||||||
|
int(i * 1.6) + (i2 * 40),
|
||||||
|
int(j * 1.6) + (j2 * 30)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tile = absfree(
|
||||||
|
3 + (i * 3) + (i2 * 40),
|
||||||
|
(j * 3) + (j2 * 30)
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tile >= 1)
|
||||||
|
{
|
||||||
|
// Fill in this pixel
|
||||||
|
FillRect(
|
||||||
|
graphics.images[12],
|
||||||
|
(i2 * 12 * map.customzoom) + i,
|
||||||
|
(j2 * 9 * map.customzoom) + j,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
graphics.getRGB(tm, tm, tm)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "BinaryBlob.h"
|
#include "BinaryBlob.h"
|
||||||
#include "Exit.h"
|
#include "Exit.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
@ -201,13 +202,8 @@ void FILESYSTEM_deinit(void)
|
||||||
{
|
{
|
||||||
PHYSFS_deinit();
|
PHYSFS_deinit();
|
||||||
}
|
}
|
||||||
if (stdin_buffer != NULL)
|
VVV_free(stdin_buffer);
|
||||||
{
|
VVV_free(basePath);
|
||||||
SDL_free(stdin_buffer);
|
|
||||||
stdin_buffer = NULL;
|
|
||||||
}
|
|
||||||
SDL_free(basePath);
|
|
||||||
basePath = NULL;
|
|
||||||
isInit = false;
|
isInit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,8 +501,6 @@ bool FILESYSTEM_isAssetMounted(const char* filename)
|
||||||
return SDL_strcmp(assetDir, realDir) == 0;
|
return SDL_strcmp(assetDir, realDir) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FILESYSTEM_freeMemory(unsigned char **mem);
|
|
||||||
|
|
||||||
static void load_stdin(void)
|
static void load_stdin(void)
|
||||||
{
|
{
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
@ -636,7 +630,7 @@ void FILESYSTEM_loadFileToMemory(
|
||||||
success = PHYSFS_readBytes(handle, *mem, length);
|
success = PHYSFS_readBytes(handle, *mem, length);
|
||||||
if (success == -1)
|
if (success == -1)
|
||||||
{
|
{
|
||||||
FILESYSTEM_freeMemory(mem);
|
VVV_free(*mem);
|
||||||
}
|
}
|
||||||
PHYSFS_close(handle);
|
PHYSFS_close(handle);
|
||||||
return;
|
return;
|
||||||
|
@ -665,12 +659,6 @@ void FILESYSTEM_loadAssetToMemory(
|
||||||
FILESYSTEM_loadFileToMemory(path, mem, len, addnull);
|
FILESYSTEM_loadFileToMemory(path, mem, len, addnull);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FILESYSTEM_freeMemory(unsigned char **mem)
|
|
||||||
{
|
|
||||||
SDL_free(*mem);
|
|
||||||
*mem = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename)
|
bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename)
|
||||||
{
|
{
|
||||||
PHYSFS_sint64 size;
|
PHYSFS_sint64 size;
|
||||||
|
@ -817,7 +805,7 @@ bool FILESYSTEM_loadTiXml2Document(const char *name, tinyxml2::XMLDocument& doc)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
doc.Parse((const char*) mem);
|
doc.Parse((const char*) mem);
|
||||||
FILESYSTEM_freeMemory(&mem);
|
VVV_free(mem);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ void FILESYSTEM_loadAssetToMemory(
|
||||||
size_t* len,
|
size_t* len,
|
||||||
const bool addnull
|
const bool addnull
|
||||||
);
|
);
|
||||||
void FILESYSTEM_freeMemory(unsigned char **mem);
|
|
||||||
|
|
||||||
bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename);
|
bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <utf8/unchecked.h>
|
#include <utf8/unchecked.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "CustomLevels.h"
|
#include "CustomLevels.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
@ -158,7 +159,7 @@ void Graphics::destroy(void)
|
||||||
#define CLEAR_ARRAY(name) \
|
#define CLEAR_ARRAY(name) \
|
||||||
for (size_t i = 0; i < name.size(); i += 1) \
|
for (size_t i = 0; i < name.size(); i += 1) \
|
||||||
{ \
|
{ \
|
||||||
SDL_FreeSurface(name[i]); \
|
VVV_freefunc(SDL_FreeSurface, name[i]); \
|
||||||
} \
|
} \
|
||||||
name.clear();
|
name.clear();
|
||||||
|
|
||||||
|
@ -228,22 +229,20 @@ void Graphics::create_buffers(const SDL_PixelFormat* fmt)
|
||||||
|
|
||||||
void Graphics::destroy_buffers(void)
|
void Graphics::destroy_buffers(void)
|
||||||
{
|
{
|
||||||
#define FREE_SURFACE(SURFACE) \
|
#define FREE_SURFACE(SURFACE) VVV_freefunc(SDL_FreeSurface, SURFACE)
|
||||||
SDL_FreeSurface(SURFACE); \
|
|
||||||
SURFACE = NULL;
|
|
||||||
|
|
||||||
FREE_SURFACE(backBuffer)
|
FREE_SURFACE(backBuffer);
|
||||||
FREE_SURFACE(footerbuffer)
|
FREE_SURFACE(footerbuffer);
|
||||||
FREE_SURFACE(ghostbuffer)
|
FREE_SURFACE(ghostbuffer);
|
||||||
FREE_SURFACE(foregroundBuffer)
|
FREE_SURFACE(foregroundBuffer);
|
||||||
FREE_SURFACE(menubuffer)
|
FREE_SURFACE(menubuffer);
|
||||||
FREE_SURFACE(warpbuffer)
|
FREE_SURFACE(warpbuffer);
|
||||||
FREE_SURFACE(warpbuffer_lerp)
|
FREE_SURFACE(warpbuffer_lerp);
|
||||||
FREE_SURFACE(towerbg.buffer)
|
FREE_SURFACE(towerbg.buffer);
|
||||||
FREE_SURFACE(towerbg.buffer_lerp)
|
FREE_SURFACE(towerbg.buffer_lerp);
|
||||||
FREE_SURFACE(titlebg.buffer)
|
FREE_SURFACE(titlebg.buffer);
|
||||||
FREE_SURFACE(titlebg.buffer_lerp)
|
FREE_SURFACE(titlebg.buffer_lerp);
|
||||||
FREE_SURFACE(tempBuffer)
|
FREE_SURFACE(tempBuffer);
|
||||||
|
|
||||||
#undef FREE_SURFACE
|
#undef FREE_SURFACE
|
||||||
}
|
}
|
||||||
|
@ -347,8 +346,7 @@ void Graphics::updatetitlecolours(void)
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
SDL_FreeSurface(grphx.im_##tilesheet); \
|
VVV_freefunc(SDL_FreeSurface, grphx.im_##tilesheet); \
|
||||||
grphx.im_##tilesheet = NULL; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PROCESS_TILESHEET(tilesheet, tile_square, extra_code) \
|
#define PROCESS_TILESHEET(tilesheet, tile_square, extra_code) \
|
||||||
|
@ -376,7 +374,7 @@ bool Graphics::Makebfont(void)
|
||||||
font_positions[codepoint] = pos;
|
font_positions[codepoint] = pos;
|
||||||
++pos;
|
++pos;
|
||||||
}
|
}
|
||||||
FILESYSTEM_freeMemory(&charmap);
|
VVV_free(charmap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -502,7 +500,7 @@ static void print_char(
|
||||||
|
|
||||||
if (scale > 1)
|
if (scale > 1)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(surface);
|
VVV_freefunc(SDL_FreeSurface, surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2179,7 +2177,7 @@ void Graphics::drawentity(const int i, const int yoff)
|
||||||
setRect(drawRect, xp, yp - yoff, sprites_rect.x * 6, sprites_rect.y * 6);
|
setRect(drawRect, xp, yp - yoff, sprites_rect.x * 6, sprites_rect.y * 6);
|
||||||
SDL_Surface* TempSurface = ScaleSurface( spritesvec[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h );
|
SDL_Surface* TempSurface = ScaleSurface( spritesvec[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h );
|
||||||
BlitSurfaceColoured(TempSurface, NULL , backBuffer, &drawRect, ct );
|
BlitSurfaceColoured(TempSurface, NULL , backBuffer, &drawRect, ct );
|
||||||
SDL_FreeSurface(TempSurface);
|
VVV_freefunc(SDL_FreeSurface, TempSurface);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "GraphicsResources.h"
|
#include "GraphicsResources.h"
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "FileSystemUtils.h"
|
#include "FileSystemUtils.h"
|
||||||
#include "Vlogging.h"
|
#include "Vlogging.h"
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ SDL_Surface* LoadImage(const char *filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
error = lodepng_decode32(&data, &width, &height, fileIn, length);
|
error = lodepng_decode32(&data, &width, &height, fileIn, length);
|
||||||
FILESYSTEM_freeMemory(&fileIn);
|
VVV_free(fileIn);
|
||||||
|
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
|
@ -61,14 +62,14 @@ SDL_Surface* LoadImage(const char *filename)
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
SDL_FreeSurface( loadedImage );
|
VVV_freefunc(SDL_FreeSurface, loadedImage);
|
||||||
SDL_free(data);
|
VVV_free(data);
|
||||||
SDL_SetSurfaceBlendMode(optimizedImage, SDL_BLENDMODE_BLEND);
|
SDL_SetSurfaceBlendMode(optimizedImage, SDL_BLENDMODE_BLEND);
|
||||||
return optimizedImage;
|
return optimizedImage;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SDL_free(data);
|
VVV_free(data);
|
||||||
vlog_error("Image not found: %s", filename);
|
vlog_error("Image not found: %s", filename);
|
||||||
SDL_assert(0 && "Image not found! See stderr.");
|
SDL_assert(0 && "Image not found! See stderr.");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -104,10 +105,7 @@ void GraphicsResources::init(void)
|
||||||
|
|
||||||
void GraphicsResources::destroy(void)
|
void GraphicsResources::destroy(void)
|
||||||
{
|
{
|
||||||
#define CLEAR(img) \
|
#define CLEAR(img) VVV_freefunc(SDL_FreeSurface, img)
|
||||||
SDL_FreeSurface(img); \
|
|
||||||
img = NULL;
|
|
||||||
|
|
||||||
CLEAR(im_tiles);
|
CLEAR(im_tiles);
|
||||||
CLEAR(im_tiles2);
|
CLEAR(im_tiles2);
|
||||||
CLEAR(im_tiles3);
|
CLEAR(im_tiles3);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
#include "Maths.h"
|
#include "Maths.h"
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ void BlitSurfaceColoured(
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_BlitSurface(tempsurface, _srcRect, _dest, tempRect);
|
SDL_BlitSurface(tempsurface, _srcRect, _dest, tempRect);
|
||||||
SDL_FreeSurface(tempsurface);
|
VVV_freefunc(SDL_FreeSurface, tempsurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlitSurfaceTinted(
|
void BlitSurfaceTinted(
|
||||||
|
@ -287,7 +288,7 @@ void BlitSurfaceTinted(
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_BlitSurface(tempsurface, _srcRect, _dest, tempRect);
|
SDL_BlitSurface(tempsurface, _srcRect, _dest, tempRect);
|
||||||
SDL_FreeSurface(tempsurface);
|
VVV_freefunc(SDL_FreeSurface, tempsurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -489,7 +490,7 @@ void ScrollSurface( SDL_Surface* _src, int _pX, int _pY )
|
||||||
//Cleanup temp surface
|
//Cleanup temp surface
|
||||||
if (part1)
|
if (part1)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(part1);
|
VVV_freefunc(SDL_FreeSurface, part1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2379,6 +2379,10 @@ void gameinput(void)
|
||||||
{
|
{
|
||||||
//Do nothing if we're in a Time Trial but a fade animation is playing
|
//Do nothing if we're in a Time Trial but a fade animation is playing
|
||||||
}
|
}
|
||||||
|
else if (map.custommode && !map.custommodeforreal)
|
||||||
|
{
|
||||||
|
// We're playtesting in the editor so don't do anything
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Normal map screen, do transition later
|
//Normal map screen, do transition later
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <utf8/unchecked.h>
|
#include <utf8/unchecked.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "Exit.h"
|
#include "Exit.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "GlitchrunnerMode.h"
|
#include "GlitchrunnerMode.h"
|
||||||
|
@ -183,7 +184,7 @@ void KeyPoll::Poll(void)
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
keybuffer += text;
|
keybuffer += text;
|
||||||
SDL_free(text);
|
VVV_free(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#define MAP_DEFINITION
|
#define MAP_DEFINITION
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "CustomLevels.h"
|
#include "CustomLevels.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
@ -48,7 +49,6 @@ mapclass::mapclass(void)
|
||||||
|
|
||||||
custommode=false;
|
custommode=false;
|
||||||
custommodeforreal=false;
|
custommodeforreal=false;
|
||||||
customwidth=20; customheight=20;
|
|
||||||
custommmxoff=0; custommmyoff=0; custommmxsize=0; custommmysize=0;
|
custommmxoff=0; custommmyoff=0; custommmxsize=0; custommmysize=0;
|
||||||
customzoom=0;
|
customzoom=0;
|
||||||
customshowmm=true;
|
customshowmm=true;
|
||||||
|
@ -81,10 +81,18 @@ mapclass::mapclass(void)
|
||||||
|
|
||||||
nexttowercolour_set = false;
|
nexttowercolour_set = false;
|
||||||
|
|
||||||
roomname = "";
|
setroomname("");
|
||||||
hiddenname = "";
|
hiddenname = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char roomname_static[SCREEN_WIDTH_CHARS];
|
||||||
|
static char* roomname_heap;
|
||||||
|
|
||||||
|
void mapclass::destroy(void)
|
||||||
|
{
|
||||||
|
VVV_free(roomname_heap);
|
||||||
|
}
|
||||||
|
|
||||||
//Areamap starts at 100,100 and extends 20x20
|
//Areamap starts at 100,100 and extends 20x20
|
||||||
const int mapclass::areamap[] = {
|
const int mapclass::areamap[] = {
|
||||||
1,2,2,2,2,2,2,2,0,3,0,0,0,4,4,4,4,4,4,4,
|
1,2,2,2,2,2,2,2,0,3,0,0,0,4,4,4,4,4,4,4,
|
||||||
|
@ -109,6 +117,30 @@ const int mapclass::areamap[] = {
|
||||||
2,2,2,2,2,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,
|
2,2,2,2,2,0,0,2,0,3,0,0,0,0,0,0,0,0,0,0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int mapclass::getwidth(void)
|
||||||
|
{
|
||||||
|
#ifndef NO_CUSTOM_LEVELS
|
||||||
|
if (custommode)
|
||||||
|
{
|
||||||
|
return cl.mapwidth;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mapclass::getheight(void)
|
||||||
|
{
|
||||||
|
#ifndef NO_CUSTOM_LEVELS
|
||||||
|
if (custommode)
|
||||||
|
{
|
||||||
|
return cl.mapheight;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
int mapclass::intpol(int a, int b, float c)
|
int mapclass::intpol(int a, int b, float c)
|
||||||
{
|
{
|
||||||
return static_cast<int>(a + ((b - a) * c));
|
return static_cast<int>(a + ((b - a) * c));
|
||||||
|
@ -116,6 +148,11 @@ int mapclass::intpol(int a, int b, float c)
|
||||||
|
|
||||||
void mapclass::setteleporter(int x, int y)
|
void mapclass::setteleporter(int x, int y)
|
||||||
{
|
{
|
||||||
|
if (x < 0 || x >= getwidth() || y < 0 || y >= getheight())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
point temp;
|
point temp;
|
||||||
temp.x = x;
|
temp.x = x;
|
||||||
temp.y = y;
|
temp.y = y;
|
||||||
|
@ -124,12 +161,36 @@ void mapclass::setteleporter(int x, int y)
|
||||||
|
|
||||||
void mapclass::settrinket(int x, int y)
|
void mapclass::settrinket(int x, int y)
|
||||||
{
|
{
|
||||||
|
if (x < 0 || x >= getwidth() || y < 0 || y >= getheight())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
point temp;
|
point temp;
|
||||||
temp.x = x;
|
temp.x = x;
|
||||||
temp.y = y;
|
temp.y = y;
|
||||||
shinytrinkets.push_back(temp);
|
shinytrinkets.push_back(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mapclass::setroomname(const char* name)
|
||||||
|
{
|
||||||
|
VVV_free(roomname_heap);
|
||||||
|
|
||||||
|
const size_t size = SDL_strlcpy(
|
||||||
|
roomname_static, name, sizeof(roomname_static)
|
||||||
|
) + 1;
|
||||||
|
roomname = roomname_static;
|
||||||
|
|
||||||
|
if (size > sizeof(roomname_static))
|
||||||
|
{
|
||||||
|
roomname_heap = SDL_strdup(name);
|
||||||
|
if (roomname_heap != NULL)
|
||||||
|
{
|
||||||
|
roomname = roomname_heap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mapclass::resetmap(void)
|
void mapclass::resetmap(void)
|
||||||
{
|
{
|
||||||
//clear the explored area of the map
|
//clear the explored area of the map
|
||||||
|
@ -1353,7 +1414,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
obj.customplatformtile=0;
|
obj.customplatformtile=0;
|
||||||
obj.vertplatforms = false;
|
obj.vertplatforms = false;
|
||||||
obj.horplatforms = false;
|
obj.horplatforms = false;
|
||||||
roomname = "";
|
setroomname("");
|
||||||
hiddenname = "";
|
hiddenname = "";
|
||||||
background = 1;
|
background = 1;
|
||||||
warpx = false;
|
warpx = false;
|
||||||
|
@ -1485,7 +1546,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
extrarow = 1;
|
extrarow = 1;
|
||||||
const short* tmap = otherlevel.loadlevel(rx, ry);
|
const short* tmap = otherlevel.loadlevel(rx, ry);
|
||||||
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
||||||
roomname = otherlevel.roomname;
|
setroomname(otherlevel.roomname);
|
||||||
hiddenname = otherlevel.hiddenname;
|
hiddenname = otherlevel.hiddenname;
|
||||||
tileset = otherlevel.roomtileset;
|
tileset = otherlevel.roomtileset;
|
||||||
break;
|
break;
|
||||||
|
@ -1494,7 +1555,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
{
|
{
|
||||||
const short* tmap = lablevel.loadlevel(rx, ry);
|
const short* tmap = lablevel.loadlevel(rx, ry);
|
||||||
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
||||||
roomname = lablevel.roomname;
|
setroomname(lablevel.roomname);
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 2;
|
background = 2;
|
||||||
graphics.rcol = lablevel.rcol;
|
graphics.rcol = lablevel.rcol;
|
||||||
|
@ -1507,7 +1568,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
graphics.towerbg.scrolldir = 0;
|
graphics.towerbg.scrolldir = 0;
|
||||||
setbgobjlerp(graphics.towerbg);
|
setbgobjlerp(graphics.towerbg);
|
||||||
|
|
||||||
roomname = "The Tower";
|
setroomname("The Tower");
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 3;
|
background = 3;
|
||||||
towermode = true;
|
towermode = true;
|
||||||
|
@ -1541,7 +1602,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
{
|
{
|
||||||
const short* tmap = warplevel.loadlevel(rx, ry);
|
const short* tmap = warplevel.loadlevel(rx, ry);
|
||||||
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
||||||
roomname = warplevel.roomname;
|
setroomname(warplevel.roomname);
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 3;
|
background = 3;
|
||||||
graphics.rcol = warplevel.rcol;
|
graphics.rcol = warplevel.rcol;
|
||||||
|
@ -1559,7 +1620,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
{
|
{
|
||||||
const short* tmap = spacestation2.loadlevel(rx, ry);
|
const short* tmap = spacestation2.loadlevel(rx, ry);
|
||||||
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
||||||
roomname = spacestation2.roomname;
|
setroomname(spacestation2.roomname);
|
||||||
tileset = 0;
|
tileset = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1567,7 +1628,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
{
|
{
|
||||||
const short* tmap = finallevel.loadlevel(rx, ry);
|
const short* tmap = finallevel.loadlevel(rx, ry);
|
||||||
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
||||||
roomname = finallevel.roomname;
|
setroomname(finallevel.roomname);
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 3;
|
background = 3;
|
||||||
graphics.backgrounddrawn = false;
|
graphics.backgrounddrawn = false;
|
||||||
|
@ -1597,7 +1658,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
graphics.towerbg.scrolldir = 1;
|
graphics.towerbg.scrolldir = 1;
|
||||||
setbgobjlerp(graphics.towerbg);
|
setbgobjlerp(graphics.towerbg);
|
||||||
|
|
||||||
roomname = "Panic Room";
|
setroomname("Panic Room");
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 3;
|
background = 3;
|
||||||
towermode = true;
|
towermode = true;
|
||||||
|
@ -1619,7 +1680,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
graphics.towerbg.scrolldir = 1;
|
graphics.towerbg.scrolldir = 1;
|
||||||
setbgobjlerp(graphics.towerbg);
|
setbgobjlerp(graphics.towerbg);
|
||||||
|
|
||||||
roomname = "Panic Room";
|
setroomname("Panic Room");
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 3;
|
background = 3;
|
||||||
towermode = true;
|
towermode = true;
|
||||||
|
@ -1648,7 +1709,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
graphics.towerbg.scrolldir = 0;
|
graphics.towerbg.scrolldir = 0;
|
||||||
setbgobjlerp(graphics.towerbg);
|
setbgobjlerp(graphics.towerbg);
|
||||||
|
|
||||||
roomname = "The Final Challenge";
|
setroomname("The Final Challenge");
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 3;
|
background = 3;
|
||||||
towermode = true;
|
towermode = true;
|
||||||
|
@ -1693,7 +1754,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
graphics.towerbg.scrolldir = 0;
|
graphics.towerbg.scrolldir = 0;
|
||||||
setbgobjlerp(graphics.towerbg);
|
setbgobjlerp(graphics.towerbg);
|
||||||
|
|
||||||
roomname = "The Final Challenge";
|
setroomname("The Final Challenge");
|
||||||
tileset = 1;
|
tileset = 1;
|
||||||
background = 3;
|
background = 3;
|
||||||
towermode = true;
|
towermode = true;
|
||||||
|
@ -1726,7 +1787,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
{
|
{
|
||||||
const short* tmap = finallevel.loadlevel(rx, ry);
|
const short* tmap = finallevel.loadlevel(rx, ry);
|
||||||
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
copy_short_to_int(contents, tmap, SDL_arraysize(contents));
|
||||||
roomname = finallevel.roomname;
|
setroomname(finallevel.roomname);
|
||||||
tileset = 2;
|
tileset = 2;
|
||||||
if (rx == 108)
|
if (rx == 108)
|
||||||
{
|
{
|
||||||
|
@ -1809,7 +1870,7 @@ void mapclass::loadlevel(int rx, int ry)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
roomname = room->roomname.c_str();
|
setroomname(room->roomname.c_str());
|
||||||
extrarow = 1;
|
extrarow = 1;
|
||||||
const int* tmap = cl.loadlevel(rx, ry);
|
const int* tmap = cl.loadlevel(rx, ry);
|
||||||
SDL_memcpy(contents, tmap, sizeof(contents));
|
SDL_memcpy(contents, tmap, sizeof(contents));
|
||||||
|
|
|
@ -22,6 +22,11 @@ class mapclass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
mapclass(void);
|
mapclass(void);
|
||||||
|
void destroy(void);
|
||||||
|
|
||||||
|
int getwidth(void);
|
||||||
|
|
||||||
|
int getheight(void);
|
||||||
|
|
||||||
int intpol(int a, int b, float c);
|
int intpol(int a, int b, float c);
|
||||||
|
|
||||||
|
@ -29,6 +34,8 @@ public:
|
||||||
|
|
||||||
void settrinket(int x, int y);
|
void settrinket(int x, int y);
|
||||||
|
|
||||||
|
void setroomname(const char* name);
|
||||||
|
|
||||||
void resetmap(void);
|
void resetmap(void);
|
||||||
|
|
||||||
void resetnames(void);
|
void resetnames(void);
|
||||||
|
@ -129,7 +136,6 @@ public:
|
||||||
//Variables for playing custom levels
|
//Variables for playing custom levels
|
||||||
bool custommode;
|
bool custommode;
|
||||||
bool custommodeforreal;
|
bool custommodeforreal;
|
||||||
int customwidth, customheight;
|
|
||||||
int custommmxoff, custommmyoff, custommmxsize, custommmysize;
|
int custommmxoff, custommmyoff, custommmxsize, custommmysize;
|
||||||
int customzoom;
|
int customzoom;
|
||||||
bool customshowmm;
|
bool customshowmm;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <FAudio.h>
|
#include <FAudio.h>
|
||||||
#include <physfsrwops.h>
|
#include <physfsrwops.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "BinaryBlob.h"
|
#include "BinaryBlob.h"
|
||||||
#include "FileSystemUtils.h"
|
#include "FileSystemUtils.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
|
|
||||||
#define malloc SDL_malloc
|
#define malloc SDL_malloc
|
||||||
#define realloc SDL_realloc
|
#define realloc SDL_realloc
|
||||||
#define free SDL_free
|
#define free VVV_free
|
||||||
#ifdef memset /* Thanks, Apple! */
|
#ifdef memset /* Thanks, Apple! */
|
||||||
#undef memset
|
#undef memset
|
||||||
#endif
|
#endif
|
||||||
|
@ -121,12 +122,12 @@ public:
|
||||||
format.cbSize = 0;
|
format.cbSize = 0;
|
||||||
valid = true;
|
valid = true;
|
||||||
end:
|
end:
|
||||||
FILESYSTEM_freeMemory(&mem);
|
VVV_free(mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispose()
|
void Dispose()
|
||||||
{
|
{
|
||||||
SDL_free(wav_buffer);
|
VVV_free(wav_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Play()
|
void Play()
|
||||||
|
@ -146,7 +147,7 @@ end:
|
||||||
FAudioVoice_GetVoiceDetails(voices[i], &details);
|
FAudioVoice_GetVoiceDetails(voices[i], &details);
|
||||||
if (details.InputChannels != format.nChannels)
|
if (details.InputChannels != format.nChannels)
|
||||||
{
|
{
|
||||||
FAudioVoice_DestroyVoice(voices[i]);
|
VVV_freefunc(FAudioVoice_DestroyVoice, voices[i]);
|
||||||
FAudio_CreateSourceVoice(faudioctx, &voices[i], &format, 0, 2.0f, NULL, NULL, NULL);
|
FAudio_CreateSourceVoice(faudioctx, &voices[i], &format, 0, 2.0f, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
const FAudioBuffer faudio_buffer = {
|
const FAudioBuffer faudio_buffer = {
|
||||||
|
@ -221,10 +222,9 @@ end:
|
||||||
{
|
{
|
||||||
for (int i = 0; i < VVV_MAX_CHANNELS; i++)
|
for (int i = 0; i < VVV_MAX_CHANNELS; i++)
|
||||||
{
|
{
|
||||||
FAudioVoice_DestroyVoice(voices[i]);
|
VVV_freefunc(FAudioVoice_DestroyVoice, voices[i]);
|
||||||
}
|
}
|
||||||
SDL_free(voices);
|
VVV_free(voices);
|
||||||
voices = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,8 +263,7 @@ public:
|
||||||
if (vorbis == NULL)
|
if (vorbis == NULL)
|
||||||
{
|
{
|
||||||
vlog_error("Unable to create Vorbis handle, error %d", err);
|
vlog_error("Unable to create Vorbis handle, error %d", err);
|
||||||
SDL_free(read_buf);
|
VVV_free(read_buf);
|
||||||
read_buf = NULL;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
vorbis_info = stb_vorbis_get_info(vorbis);
|
vorbis_info = stb_vorbis_get_info(vorbis);
|
||||||
|
@ -295,13 +294,12 @@ end:
|
||||||
void Dispose()
|
void Dispose()
|
||||||
{
|
{
|
||||||
stb_vorbis_close(vorbis);
|
stb_vorbis_close(vorbis);
|
||||||
SDL_free(read_buf);
|
VVV_free(read_buf);
|
||||||
SDL_free(decoded_buf_playing);
|
VVV_free(decoded_buf_playing);
|
||||||
SDL_free(decoded_buf_reserve);
|
VVV_free(decoded_buf_reserve);
|
||||||
if (!IsHalted())
|
if (!IsHalted())
|
||||||
{
|
{
|
||||||
FAudioVoice_DestroyVoice(musicVoice);
|
VVV_freefunc(FAudioVoice_DestroyVoice, musicVoice);
|
||||||
musicVoice = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,8 +356,7 @@ end:
|
||||||
if (!IsHalted())
|
if (!IsHalted())
|
||||||
{
|
{
|
||||||
FAudioSourceVoice_FlushSourceBuffers(musicVoice);
|
FAudioSourceVoice_FlushSourceBuffers(musicVoice);
|
||||||
FAudioVoice_DestroyVoice(musicVoice);
|
VVV_freefunc(FAudioVoice_DestroyVoice, musicVoice);
|
||||||
musicVoice = NULL;
|
|
||||||
paused = true;
|
paused = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,11 +532,11 @@ end:
|
||||||
t->loopbegin = 0;
|
t->loopbegin = 0;
|
||||||
t->looplength = 0;
|
t->looplength = 0;
|
||||||
loopend = 0;
|
loopend = 0;
|
||||||
SDL_free(param);
|
VVV_free(param);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_free(param);
|
VVV_free(param);
|
||||||
}
|
}
|
||||||
if (loopend != 0)
|
if (loopend != 0)
|
||||||
{
|
{
|
||||||
|
@ -792,14 +789,8 @@ void musicclass::destroy(void)
|
||||||
|
|
||||||
pppppp_blob.clear();
|
pppppp_blob.clear();
|
||||||
mmmmmm_blob.clear();
|
mmmmmm_blob.clear();
|
||||||
if (masteringvoice != NULL)
|
VVV_freefunc(FAudioVoice_DestroyVoice, masteringvoice);
|
||||||
{
|
VVV_freefunc(FAudio_Release, faudioctx);
|
||||||
FAudioVoice_DestroyVoice(masteringvoice);
|
|
||||||
}
|
|
||||||
if (faudioctx != NULL)
|
|
||||||
{
|
|
||||||
FAudio_Release(faudioctx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void musicclass::play(int t)
|
void musicclass::play(int t)
|
||||||
|
|
|
@ -24,6 +24,15 @@ static int tr;
|
||||||
static int tg;
|
static int tg;
|
||||||
static int tb;
|
static int tb;
|
||||||
|
|
||||||
|
struct MapRenderData
|
||||||
|
{
|
||||||
|
int zoom;
|
||||||
|
int xoff;
|
||||||
|
int yoff;
|
||||||
|
int legendxoff;
|
||||||
|
int legendyoff;
|
||||||
|
};
|
||||||
|
|
||||||
static inline void drawslowdowntext(void)
|
static inline void drawslowdowntext(void)
|
||||||
{
|
{
|
||||||
switch (game.slowdown)
|
switch (game.slowdown)
|
||||||
|
@ -2040,6 +2049,143 @@ static void draw_roomname_menu(void)
|
||||||
* the same in Flip Mode. */
|
* the same in Flip Mode. */
|
||||||
#define FLIP(y, h) (graphics.flipmode ? 220 - (y) - (h) : (y))
|
#define FLIP(y, h) (graphics.flipmode ? 220 - (y) - (h) : (y))
|
||||||
|
|
||||||
|
static MapRenderData getmaprenderdata()
|
||||||
|
{
|
||||||
|
MapRenderData data;
|
||||||
|
|
||||||
|
data.zoom = map.custommode ? map.customzoom : 1;
|
||||||
|
data.xoff = map.custommode ? map.custommmxoff : 0;
|
||||||
|
data.yoff = map.custommode ? map.custommmyoff : 0;
|
||||||
|
data.legendxoff = 40 + data.xoff;
|
||||||
|
data.legendyoff = 21 + data.yoff;
|
||||||
|
|
||||||
|
// Magic numbers for centering legend tiles.
|
||||||
|
switch (data.zoom)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
data.legendxoff += 21;
|
||||||
|
data.legendyoff += 16;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
data.legendxoff += 9;
|
||||||
|
data.legendyoff += 5;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
data.legendxoff += 3;
|
||||||
|
data.legendyoff += 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rendermap(void)
|
||||||
|
{
|
||||||
|
#ifndef NO_CUSTOM_LEVELS
|
||||||
|
if (map.custommode)
|
||||||
|
{
|
||||||
|
graphics.drawpixeltextbox(35 + map.custommmxoff, 16 + map.custommmyoff, map.custommmxsize + 10, map.custommmysize + 10, 65, 185, 207);
|
||||||
|
graphics.drawpartimage(graphics.minimap_mounted ? 1 : 12, 40 + map.custommmxoff, 21 + map.custommmyoff, map.custommmxsize, map.custommmysize);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif /* NO_CUSTOM_LEVELS */
|
||||||
|
|
||||||
|
graphics.drawpixeltextbox(35, 16, 250, 190, 65, 185, 207);
|
||||||
|
graphics.drawimage(1, 40, 21, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rendermapfog(void)
|
||||||
|
{
|
||||||
|
const MapRenderData data = getmaprenderdata();
|
||||||
|
|
||||||
|
for (int j = 0; j < map.getheight(); j++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < map.getwidth(); i++)
|
||||||
|
{
|
||||||
|
if (!map.isexplored(i, j))
|
||||||
|
{
|
||||||
|
// Draw the fog, depending on the custom zoom size
|
||||||
|
for (int x = 0; x < data.zoom; x++)
|
||||||
|
{
|
||||||
|
for (int y = 0; y < data.zoom; y++)
|
||||||
|
{
|
||||||
|
graphics.drawimage(2, data.xoff + 40 + (x * 12) + (i * (12 * data.zoom)), data.yoff + 21 + (y * 9) + (j * (9 * data.zoom)), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rendermaplegend(void)
|
||||||
|
{
|
||||||
|
// Draw the map legend, aka teleports/targets/trinkets
|
||||||
|
|
||||||
|
const MapRenderData data = getmaprenderdata();
|
||||||
|
|
||||||
|
const int tile_offset = graphics.flipmode ? 3 : 0;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < map.teleporters.size(); i++)
|
||||||
|
{
|
||||||
|
if (map.showteleporters && map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
||||||
|
{
|
||||||
|
graphics.drawtile(data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), 1127 + tile_offset);
|
||||||
|
}
|
||||||
|
else if (map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
||||||
|
{
|
||||||
|
graphics.drawtile(data.legendxoff + (map.teleporters[i].x * 12 * data.zoom), data.legendyoff + (map.teleporters[i].y * 9 * data.zoom), 1126 + tile_offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (map.showtrinkets)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < map.shinytrinkets.size(); i++)
|
||||||
|
{
|
||||||
|
if (!obj.collect[i])
|
||||||
|
{
|
||||||
|
graphics.drawtile(data.legendxoff + (map.shinytrinkets[i].x * 12 * data.zoom), data.legendyoff + (map.shinytrinkets[i].y * 9 * data.zoom), 1086 + tile_offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rendermapcursor(const bool flashing)
|
||||||
|
{
|
||||||
|
const MapRenderData data = getmaprenderdata();
|
||||||
|
|
||||||
|
if (!map.custommode && game.roomx == 109)
|
||||||
|
{
|
||||||
|
// Draw the tower specially
|
||||||
|
if (!flashing)
|
||||||
|
{
|
||||||
|
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2, 21 + 2, 12 - 4, 180 - 4, 16, 245 - (help.glow * 2), 245 - (help.glow * 2));
|
||||||
|
}
|
||||||
|
else if (map.cursorstate == 1)
|
||||||
|
{
|
||||||
|
if (int(map.cursordelay / 4) % 2 == 0)
|
||||||
|
{
|
||||||
|
graphics.drawrect(40 + ((game.roomx - 100) * 12), 21, 12, 180, 255, 255, 255);
|
||||||
|
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2, 21 + 2, 12 - 4, 180 - 4, 255, 255, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (map.cursorstate == 2 && (int(map.cursordelay / 15) % 2 == 0))
|
||||||
|
{
|
||||||
|
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2, 21 + 2, 12 - 4, 180 - 4, 16, 245 - (help.glow), 245 - (help.glow));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flashing || (map.cursorstate == 2 && int(map.cursordelay / 15) % 2 == 0))
|
||||||
|
{
|
||||||
|
graphics.drawrect(40 + ((game.roomx - 100) * 12 * data.zoom) + 2 + data.xoff, 21 + ((game.roomy - 100) * 9 * data.zoom) + 2 + data.yoff, (12 * data.zoom) - 4, (9 * data.zoom) - 4, 16, 245 - (help.glow), 245 - (help.glow));
|
||||||
|
}
|
||||||
|
else if (map.cursorstate == 1 && (int(map.cursordelay / 4) % 2 == 0))
|
||||||
|
{
|
||||||
|
graphics.drawrect(40 + ((game.roomx - 100) * 12 * data.zoom) + data.xoff, 21 + ((game.roomy - 100) * 9 * data.zoom) + data.yoff, 12 * data.zoom, 9 * data.zoom, 255, 255, 255);
|
||||||
|
graphics.drawrect(40 + ((game.roomx - 100) * 12 * data.zoom) + 2 + data.xoff, 21 + ((game.roomy - 100) * 9 * data.zoom) + 2 + data.yoff, (12 * data.zoom) - 4, (9 * data.zoom) - 4, 255, 255, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void maprender(void)
|
void maprender(void)
|
||||||
{
|
{
|
||||||
ClearSurface(graphics.backBuffer);
|
ClearSurface(graphics.backBuffer);
|
||||||
|
@ -2049,8 +2195,6 @@ void maprender(void)
|
||||||
//Background color
|
//Background color
|
||||||
FillRect(graphics.backBuffer,0, 12, 320, 240, 10, 24, 26 );
|
FillRect(graphics.backBuffer,0, 12, 320, 240, 10, 24, 26 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Menubar:
|
//Menubar:
|
||||||
graphics.drawtextbox( -10, 212, 43, 3, 65, 185, 207);
|
graphics.drawtextbox( -10, 212, 43, 3, 65, 185, 207);
|
||||||
|
|
||||||
|
@ -2108,11 +2252,11 @@ void maprender(void)
|
||||||
switch(game.menupage)
|
switch(game.menupage)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
rendermap();
|
||||||
|
|
||||||
if (map.finalmode || (map.custommode&&!map.customshowmm))
|
if (map.finalmode || (map.custommode&&!map.customshowmm))
|
||||||
{
|
{
|
||||||
//draw the map image
|
// Cover the whole map
|
||||||
graphics.drawpixeltextbox(35, 16, 250, 190, 65, 185, 207);
|
|
||||||
graphics.drawimage(1, 40, 21, false);
|
|
||||||
for (int j = 0; j < 20; j++)
|
for (int j = 0; j < 20; j++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
|
@ -2122,211 +2266,11 @@ void maprender(void)
|
||||||
}
|
}
|
||||||
graphics.bprint(-1, 105, "NO SIGNAL", 245, 245, 245, true);
|
graphics.bprint(-1, 105, "NO SIGNAL", 245, 245, 245, true);
|
||||||
}
|
}
|
||||||
#ifndef NO_CUSTOM_LEVELS
|
|
||||||
else if(map.custommode)
|
|
||||||
{
|
|
||||||
//draw the map image
|
|
||||||
graphics.drawpixeltextbox(35+map.custommmxoff, 16+map.custommmyoff, map.custommmxsize+10, map.custommmysize+10, 65, 185, 207);
|
|
||||||
if (graphics.minimap_mounted)
|
|
||||||
{
|
|
||||||
graphics.drawpartimage(1, 40+map.custommmxoff, 21+map.custommmyoff, map.custommmxsize, map.custommmysize);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
graphics.drawpartimage(12, 40+map.custommmxoff, 21+map.custommmyoff, map.custommmxsize,map.custommmysize);
|
rendermapfog();
|
||||||
}
|
rendermapcursor(true);
|
||||||
|
rendermaplegend();
|
||||||
//Black out here
|
|
||||||
if(map.customzoom==4){
|
|
||||||
for (int j = 0; j < map.customheight; j++){
|
|
||||||
for (int i = 0; i < map.customwidth; i++){
|
|
||||||
if(!map.isexplored(i, j)){
|
|
||||||
//Draw the fog of war on the map
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48), map.custommmyoff+21 + (j * 36), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48), map.custommmyoff+21 + (j * 36), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48), map.custommmyoff+21 + 9 + (j * 36), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48), map.custommmyoff+21 + 9+ (j * 36), false);
|
|
||||||
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48) + 24, map.custommmyoff+21 + (j * 36), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48) + 24, map.custommmyoff+21 + (j * 36), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48) + 24, map.custommmyoff+ 21 + 9 + (j * 36), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48) + 24, map.custommmyoff+21 + 9+ (j * 36), false);
|
|
||||||
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48), map.custommmyoff+21 + (j * 36)+18, false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48), map.custommmyoff+21 + (j * 36)+18, false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48), map.custommmyoff+21 + 9 + (j * 36)+18, false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48), map.custommmyoff+21 + 9+ (j * 36)+18, false);
|
|
||||||
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48) + 24, map.custommmyoff+21 + (j * 36)+18, false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48) + 24, map.custommmyoff+21 + (j * 36)+18, false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 48) + 24, map.custommmyoff+21 + 9 + (j * 36)+18, false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 48) + 24, map.custommmyoff+21 + 9+ (j * 36)+18, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(map.customzoom==2){
|
|
||||||
for (int j = 0; j < map.customheight; j++){
|
|
||||||
for (int i = 0; i < map.customwidth; i++){
|
|
||||||
if(!map.isexplored(i, j)){
|
|
||||||
//Draw the fog of war on the map
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 24), map.custommmyoff+21 + (j * 18), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 24), map.custommmyoff+21 + (j * 18), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 24), map.custommmyoff+21 + 9 + (j * 18), false);
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + 12 + (i * 24), map.custommmyoff+21 + 9+ (j * 18), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
for (int j = 0; j < map.customheight; j++){
|
|
||||||
for (int i = 0; i < map.customwidth; i++){
|
|
||||||
if(!map.isexplored(i, j)){
|
|
||||||
//Draw the fog of war on the map
|
|
||||||
graphics.drawimage(2, map.custommmxoff+40 + (i * 12), map.custommmyoff+21 + (j * 9), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//normal size maps
|
|
||||||
if(map.customzoom==4){
|
|
||||||
if(map.cursorstate==1){
|
|
||||||
if (int(map.cursordelay / 4) % 2 == 0){
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 48) +map.custommmxoff, 21 + ((game.roomy - 100) * 36)+map.custommmyoff , 48 , 36 , 255,255,255);
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 48) + 2+map.custommmxoff, 21 + ((game.roomy - 100) * 36) + 2+map.custommmyoff, 48 - 4, 36 - 4, 255,255,255);
|
|
||||||
}
|
|
||||||
}else if (map.cursorstate == 2){
|
|
||||||
if (int(map.cursordelay / 15) % 2 == 0){
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 48) + 2+map.custommmxoff, 21 + ((game.roomy - 100) * 36) + 2+map.custommmyoff, 48 - 4, 36 - 4, 16, 245 - (help.glow), 245 - (help.glow));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(map.customzoom==2){
|
|
||||||
if(map.cursorstate==1){
|
|
||||||
if (int(map.cursordelay / 4) % 2 == 0){
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 24)+map.custommmxoff , 21 + ((game.roomy - 100) * 18)+map.custommmyoff , 24 , 18 , 255,255,255);
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 24) + 2+map.custommmxoff, 21 + ((game.roomy - 100) * 18) + 2+map.custommmyoff, 24 - 4, 18 - 4, 255,255,255);
|
|
||||||
}
|
|
||||||
}else if (map.cursorstate == 2){
|
|
||||||
if (int(map.cursordelay / 15) % 2 == 0){
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 24) + 2+map.custommmxoff, 21 + ((game.roomy - 100) * 18) + 2+map.custommmyoff, 24 - 4, 18 - 4, 16, 245 - (help.glow), 245 - (help.glow));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if(map.cursorstate==1){
|
|
||||||
if (int(map.cursordelay / 4) % 2 == 0){
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12)+map.custommmxoff , 21 + ((game.roomy - 100) * 9)+map.custommmyoff , 12 , 9 , 255,255,255);
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2+map.custommmxoff, 21 + ((game.roomy - 100) * 9) + 2+map.custommmyoff, 12 - 4, 9 - 4, 255,255,255);
|
|
||||||
}
|
|
||||||
}else if (map.cursorstate == 2){
|
|
||||||
if (int(map.cursordelay / 15) % 2 == 0){
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2+map.custommmxoff, 21 + ((game.roomy - 100) * 9) + 2+map.custommmyoff, 12 - 4, 9 - 4, 16, 245 - (help.glow), 245 - (help.glow));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(map.showtrinkets){
|
|
||||||
for(size_t i=0; i<map.shinytrinkets.size(); i++){
|
|
||||||
if(!obj.collect[i]){
|
|
||||||
int temp = 1086;
|
|
||||||
if(graphics.flipmode) temp += 3;
|
|
||||||
if(map.customzoom==4){
|
|
||||||
graphics.drawtile(40 + (map.shinytrinkets[i].x * 48) + 20+map.custommmxoff, 21 + (map.shinytrinkets[i].y * 36) + 14+map.custommmyoff, temp);
|
|
||||||
}else if(map.customzoom==2){
|
|
||||||
graphics.drawtile(40 + (map.shinytrinkets[i].x * 24) + 8+map.custommmxoff, 21 + (map.shinytrinkets[i].y * 18) + 5+map.custommmyoff, temp);
|
|
||||||
}else{
|
|
||||||
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12) + map.custommmxoff, 22 + (map.shinytrinkets[i].y * 9) + map.custommmyoff, temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* NO_CUSTOM_LEVELS */
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//draw the map image
|
|
||||||
graphics.drawpixeltextbox(35, 16, 250, 190, 65, 185, 207);
|
|
||||||
graphics.drawimage(1, 40, 21, false);
|
|
||||||
|
|
||||||
//black out areas we can't see yet
|
|
||||||
for (int j = 0; j < 20; j++)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 20; i++)
|
|
||||||
{
|
|
||||||
if(!map.isexplored(i, j))
|
|
||||||
{
|
|
||||||
//Draw the fog of war on the map
|
|
||||||
graphics.drawimage(2, 40 + (i * 12), 21 + (j * 9), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//draw the coordinates
|
|
||||||
if (game.roomx == 109)
|
|
||||||
{
|
|
||||||
//tower!instead of room y, scale map.ypos
|
|
||||||
if (map.cursorstate == 1)
|
|
||||||
{
|
|
||||||
if (int(map.cursordelay / 4) % 2 == 0)
|
|
||||||
{
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) , 21 , 12, 180, 255,255,255);
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2 , 21 + 2, 12 - 4, 180 - 4, 255,255,255);
|
|
||||||
}
|
|
||||||
if (map.cursordelay > 30) map.cursorstate = 2;
|
|
||||||
}
|
|
||||||
else if (map.cursorstate == 2)
|
|
||||||
{
|
|
||||||
if (int(map.cursordelay / 15) % 2 == 0)
|
|
||||||
{
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2 , 21 + 2, 12 - 4, 180 - 4,16, 245 - (help.glow), 245 - (help.glow));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (map.cursorstate == 1)
|
|
||||||
{
|
|
||||||
if (int(map.cursordelay / 4) % 2 == 0)
|
|
||||||
{
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) , 21 + ((game.roomy - 100) * 9) , 12 , 9 , 255,255,255);
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2, 21 + ((game.roomy - 100) * 9) + 2, 12 - 4, 9 - 4, 255,255,255);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (map.cursorstate == 2)
|
|
||||||
{
|
|
||||||
if (int(map.cursordelay / 15) % 2 == 0)
|
|
||||||
{
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2, 21 + ((game.roomy - 100) * 9) + 2, 12 - 4, 9 - 4, 16, 245 - (help.glow), 245 - (help.glow));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//draw legend details
|
|
||||||
for (size_t i = 0; i < map.teleporters.size(); i++)
|
|
||||||
{
|
|
||||||
if (map.showteleporters && map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
|
||||||
{
|
|
||||||
int temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
|
||||||
if (graphics.flipmode) temp += 3;
|
|
||||||
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
|
|
||||||
}
|
|
||||||
else if(map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
|
||||||
{
|
|
||||||
int temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
|
||||||
if (graphics.flipmode) temp += 3;
|
|
||||||
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map.showtrinkets)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < map.shinytrinkets.size(); i++)
|
|
||||||
{
|
|
||||||
if (!obj.collect[i])
|
|
||||||
{
|
|
||||||
int temp = 1086;
|
|
||||||
if (graphics.flipmode) temp += 3;
|
|
||||||
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -2736,31 +2680,13 @@ void teleporterrender(void)
|
||||||
//Background color
|
//Background color
|
||||||
FillRect(graphics.backBuffer, 0, 12, 320, 240, 10, 24, 26);
|
FillRect(graphics.backBuffer, 0, 12, 320, 240, 10, 24, 26);
|
||||||
|
|
||||||
//draw the map image
|
rendermap();
|
||||||
graphics.drawpixeltextbox(35, 16, 250, 190, 65, 185, 207);
|
rendermapfog();
|
||||||
graphics.drawimage(1, 40, 21, false);
|
rendermapcursor(false);
|
||||||
//black out areas we can't see yet
|
|
||||||
for (int j = 0; j < 20; j++)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 20; i++)
|
|
||||||
{
|
|
||||||
if(!map.isexplored(i, j))
|
|
||||||
{
|
|
||||||
graphics.drawimage(2, 40 + (i * 12), 21 + (j * 9), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//draw the coordinates //current
|
// Draw a box around the currently selected teleporter
|
||||||
if (game.roomx == 109)
|
|
||||||
{
|
const MapRenderData data = getmaprenderdata();
|
||||||
//tower!instead of room y, scale map.ypos
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2, 21 + 2, 12 - 4, 180 - 4, 16, 245 - (help.glow * 2), 245 - (help.glow * 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
graphics.drawrect(40 + ((game.roomx - 100) * 12) + 2, 21 + ((game.roomy - 100) * 9) + 2, 12 - 4, 9 - 4, 16, 245 - (help.glow * 2), 245 - (help.glow * 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (game.useteleporter)
|
if (game.useteleporter)
|
||||||
{
|
{
|
||||||
|
@ -2769,48 +2695,21 @@ void teleporterrender(void)
|
||||||
//draw the coordinates //destination
|
//draw the coordinates //destination
|
||||||
int tempx_ = map.teleporters[game.teleport_to_teleporter].x;
|
int tempx_ = map.teleporters[game.teleport_to_teleporter].x;
|
||||||
int tempy_ = map.teleporters[game.teleport_to_teleporter].y;
|
int tempy_ = map.teleporters[game.teleport_to_teleporter].y;
|
||||||
graphics.drawrect(40 + (tempx_ * 12) + 1, 21 + (tempy_ * 9) + 1, 12 - 2, 9 - 2, 245 - (help.glow * 2), 16, 16);
|
graphics.drawrect(40 + data.xoff + (tempx_ * 12 * data.zoom) + 1, 21 + data.yoff + (tempy_ * 9 * data.zoom) + 1, 12 * data.zoom - 2, 9 * data.zoom - 2, 245 - (help.glow * 2), 16, 16);
|
||||||
graphics.drawrect(40 + (tempx_ * 12) + 3, 21 + (tempy_ * 9) + 3, 12 - 6, 9 - 6, 245 - (help.glow * 2), 16, 16);
|
graphics.drawrect(40 + data.xoff + (tempx_ * 12 * data.zoom) + 3, 21 + data.yoff + (tempy_ * 9 * data.zoom) + 3, 12 * data.zoom - 6, 9 * data.zoom - 6, 245 - (help.glow * 2), 16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw legend details
|
// Draw the legend itself
|
||||||
for (size_t i = 0; i < map.teleporters.size(); i++)
|
|
||||||
{
|
|
||||||
if (map.showteleporters && map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
|
||||||
{
|
|
||||||
int temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
|
||||||
if (graphics.flipmode) temp += 3;
|
|
||||||
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
|
|
||||||
}
|
|
||||||
else if(map.showtargets && !map.isexplored(map.teleporters[i].x, map.teleporters[i].y))
|
|
||||||
{
|
|
||||||
int temp = 1126 + (int) map.isexplored(map.teleporters[i].x, map.teleporters[i].y);
|
|
||||||
if (graphics.flipmode) temp += 3;
|
|
||||||
graphics.drawtile(40 + 3 + (map.teleporters[i].x * 12), 22 + (map.teleporters[i].y * 9), temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (map.showtrinkets)
|
rendermaplegend();
|
||||||
{
|
|
||||||
for (size_t i = 0; i < map.shinytrinkets.size(); i++)
|
// Highlight the currently selected teleporter
|
||||||
{
|
|
||||||
if (!obj.collect[i])
|
|
||||||
{
|
|
||||||
int temp = 1086;
|
|
||||||
if (graphics.flipmode) temp += 3;
|
|
||||||
graphics.drawtile(40 + 3 + (map.shinytrinkets[i].x * 12), 22 + (map.shinytrinkets[i].y * 9), temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tempx = map.teleporters[game.teleport_to_teleporter].x;
|
tempx = map.teleporters[game.teleport_to_teleporter].x;
|
||||||
tempy = map.teleporters[game.teleport_to_teleporter].y;
|
tempy = map.teleporters[game.teleport_to_teleporter].y;
|
||||||
if (game.useteleporter && ((help.slowsine%16)>8))
|
if (game.useteleporter && help.slowsine % 16 > 8)
|
||||||
{
|
{
|
||||||
//colour in the legend
|
graphics.drawtile(data.legendxoff + data.xoff + (tempx * 12 * data.zoom), data.legendyoff + data.yoff + (tempy * 9 * data.zoom), 1128 + (graphics.flipmode ? 3 : 0));
|
||||||
int temp = 1128;
|
|
||||||
if (graphics.flipmode) temp += 3;
|
|
||||||
graphics.drawtile(40 + 3 + (tempx * 12), 22 + (tempy * 9), temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics.cutscenebars();
|
graphics.cutscenebars();
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "FileSystemUtils.h"
|
#include "FileSystemUtils.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
@ -81,17 +82,11 @@ void Screen::init(const struct ScreenSettings* settings)
|
||||||
|
|
||||||
void Screen::destroy(void)
|
void Screen::destroy(void)
|
||||||
{
|
{
|
||||||
#define X(CLEANUP, POINTER) \
|
|
||||||
CLEANUP(POINTER); \
|
|
||||||
POINTER = NULL;
|
|
||||||
|
|
||||||
/* Order matters! */
|
/* Order matters! */
|
||||||
X(SDL_DestroyTexture, m_screenTexture);
|
VVV_freefunc(SDL_DestroyTexture, m_screenTexture);
|
||||||
X(SDL_FreeSurface, m_screen);
|
VVV_freefunc(SDL_FreeSurface, m_screen);
|
||||||
X(SDL_DestroyRenderer, m_renderer);
|
VVV_freefunc(SDL_DestroyRenderer, m_renderer);
|
||||||
X(SDL_DestroyWindow, m_window);
|
VVV_freefunc(SDL_DestroyWindow, m_window);
|
||||||
|
|
||||||
#undef X
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Screen::GetSettings(struct ScreenSettings* settings)
|
void Screen::GetSettings(struct ScreenSettings* settings)
|
||||||
|
@ -126,7 +121,7 @@ void Screen::LoadIcon(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDL_SetWindowIcon(m_window, icon);
|
SDL_SetWindowIcon(m_window, icon);
|
||||||
SDL_FreeSurface(icon);
|
VVV_freefunc(SDL_FreeSurface, icon);
|
||||||
}
|
}
|
||||||
#endif /* __APPLE__ */
|
#endif /* __APPLE__ */
|
||||||
|
|
||||||
|
@ -279,7 +274,7 @@ void Screen::UpdateScreen(SDL_Surface* buffer, SDL_Rect* rect )
|
||||||
|
|
||||||
if(badSignalEffect)
|
if(badSignalEffect)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(buffer);
|
VVV_freefunc(SDL_FreeSurface, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2888,10 +2888,17 @@ void scriptclass::startgamemode( int t )
|
||||||
map.resetplayer();
|
map.resetplayer();
|
||||||
map.gotoroom(game.saverx, game.savery);
|
map.gotoroom(game.saverx, game.savery);
|
||||||
map.initmapdata();
|
map.initmapdata();
|
||||||
if(cl.levmusic>0){
|
|
||||||
|
cl.generatecustomminimap();
|
||||||
|
map.customshowmm = true;
|
||||||
|
|
||||||
|
if (cl.levmusic > 0)
|
||||||
|
{
|
||||||
music.play(cl.levmusic);
|
music.play(cl.levmusic);
|
||||||
}else{
|
}
|
||||||
music.currentsong=-1;
|
else
|
||||||
|
{
|
||||||
|
music.currentsong = -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
# endif /* NO_EDITOR */
|
# endif /* NO_EDITOR */
|
||||||
|
@ -3543,7 +3550,7 @@ void scriptclass::loadcustom(const std::string& t)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int ti=help.Int(words[1].c_str());
|
int ti=help.Int(words[1].c_str());
|
||||||
int nti = ti>=0 && ti<=50 ? ti : 1;
|
int nti = ti>=0 ? ti : 1;
|
||||||
for(int ti2=0; ti2<nti; ti2++){
|
for(int ti2=0; ti2<nti; ti2++){
|
||||||
i++;
|
i++;
|
||||||
if(INBOUNDS_VEC(i, lines)){
|
if(INBOUNDS_VEC(i, lines)){
|
||||||
|
@ -3568,7 +3575,7 @@ void scriptclass::loadcustom(const std::string& t)
|
||||||
add("text(cyan,0,0,"+words[1]+")");
|
add("text(cyan,0,0,"+words[1]+")");
|
||||||
|
|
||||||
int ti=help.Int(words[1].c_str());
|
int ti=help.Int(words[1].c_str());
|
||||||
int nti = ti>=0 && ti<=50 ? ti : 1;
|
int nti = ti>=0 ? ti : 1;
|
||||||
for(int ti2=0; ti2<nti; ti2++){
|
for(int ti2=0; ti2<nti; ti2++){
|
||||||
i++;
|
i++;
|
||||||
if(INBOUNDS_VEC(i, lines)){
|
if(INBOUNDS_VEC(i, lines)){
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include <SDL_stdinc.h>
|
#include <SDL_stdinc.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
|
|
||||||
/* Handle third-party dependencies' needs here */
|
/* Handle third-party dependencies' needs here */
|
||||||
|
|
||||||
void* lodepng_malloc(size_t size)
|
void* lodepng_malloc(size_t size)
|
||||||
|
@ -14,5 +16,5 @@ void* lodepng_realloc(void* ptr, size_t new_size)
|
||||||
|
|
||||||
void lodepng_free(void* ptr)
|
void lodepng_free(void* ptr)
|
||||||
{
|
{
|
||||||
SDL_free(ptr);
|
VVV_free(ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "Alloc.h"
|
||||||
#include "CWrappers.h"
|
#include "CWrappers.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,8 +65,8 @@ static inline void call_with_upper(format_callback callback, void* userdata, con
|
||||||
/* Never mind the capitalization then! Better than nothing. */
|
/* Never mind the capitalization then! Better than nothing. */
|
||||||
callback(userdata, string, bytes);
|
callback(userdata, string, bytes);
|
||||||
|
|
||||||
SDL_free(utf32);
|
VVV_free(utf32);
|
||||||
SDL_free(utf8);
|
VVV_free(utf8);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +79,8 @@ static inline void call_with_upper(format_callback callback, void* userdata, con
|
||||||
|
|
||||||
callback(userdata, utf8, SDL_strlen(utf8));
|
callback(userdata, utf8, SDL_strlen(utf8));
|
||||||
|
|
||||||
SDL_free(utf32);
|
VVV_free(utf32);
|
||||||
SDL_free(utf8);
|
VVV_free(utf8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -263,7 +264,7 @@ void vformat_cb_valist(
|
||||||
{
|
{
|
||||||
callback(userdata, number, SDL_strlen(number));
|
callback(userdata, number, SDL_strlen(number));
|
||||||
}
|
}
|
||||||
SDL_free(number);
|
VVV_free(number);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -458,7 +459,7 @@ char* vformat_alloc(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* Format to an automatically allocated and resized buffer.
|
/* Format to an automatically allocated and resized buffer.
|
||||||
* Caller must SDL_free. */
|
* Caller must VVV_free. */
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, args_index);
|
va_start(args, args_index);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* - vformat_cb Calls a user-supplied callback function for each part of
|
* - vformat_cb Calls a user-supplied callback function for each part of
|
||||||
* the resulting string.
|
* the resulting string.
|
||||||
* - vformat_buf Fills a user-supplied buffer with the result.
|
* - vformat_buf Fills a user-supplied buffer with the result.
|
||||||
* - vformat_alloc Allocates a buffer with the result (caller must SDL_free).
|
* - vformat_alloc Allocates a buffer with the result (caller must VVV_free).
|
||||||
*
|
*
|
||||||
* All include the following parameters:
|
* All include the following parameters:
|
||||||
* - format_string The string which needs placeholders to be filled in
|
* - format_string The string which needs placeholders to be filled in
|
||||||
|
|
|
@ -755,6 +755,7 @@ static void cleanup(void)
|
||||||
graphics.destroy_buffers();
|
graphics.destroy_buffers();
|
||||||
graphics.destroy();
|
graphics.destroy();
|
||||||
music.destroy();
|
music.destroy();
|
||||||
|
map.destroy();
|
||||||
NETWORK_shutdown();
|
NETWORK_shutdown();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
FILESYSTEM_deinit();
|
FILESYSTEM_deinit();
|
||||||
|
|
Loading…
Reference in a new issue