2010-08-26 06:38:24 -05:00
|
|
|
/**
|
|
|
|
* Powder Toy - Main source
|
|
|
|
*
|
2011-03-10 14:43:27 -06:00
|
|
|
* Copyright (c) 2008 - 2011 Stanislaw Skowronek.
|
|
|
|
* Copyright (c) 2010 - 2011 Simon Robertshaw
|
|
|
|
* Copyright (c) 2010 - 2011 Skresanov Savely
|
|
|
|
* Copyright (c) 2010 - 2011 Bryan Hoyle
|
|
|
|
* Copyright (c) 2010 - 2011 Nathan Cousins
|
|
|
|
* Copyright (c) 2010 - 2011 cracker64
|
|
|
|
* Copyright (c) 2011 jacksonmj
|
2010-08-26 06:38:24 -05:00
|
|
|
*
|
|
|
|
* 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 02111-1301 USA
|
|
|
|
*/
|
|
|
|
|
2011-03-10 14:43:27 -06:00
|
|
|
#include <defines.h>
|
|
|
|
|
2010-08-26 06:38:24 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <SDL/SDL.h>
|
2011-02-01 19:35:41 -06:00
|
|
|
#include <SDL/SDL_audio.h>
|
2010-08-26 06:38:24 -05:00
|
|
|
#include <bzlib.h>
|
|
|
|
#include <time.h>
|
2011-04-24 11:49:33 -05:00
|
|
|
#include <pthread.h>
|
2010-08-26 06:38:24 -05:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#include <direct.h>
|
|
|
|
#else
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2010-10-03 23:27:40 -05:00
|
|
|
#include <misc.h>
|
|
|
|
#include <font.h>
|
|
|
|
#include <powder.h>
|
2011-12-10 09:23:33 -06:00
|
|
|
#include "gravity.h"
|
2010-10-03 23:27:40 -05:00
|
|
|
#include <graphics.h>
|
2011-11-12 14:44:15 -06:00
|
|
|
#include <powdergraphics.h>
|
2010-10-03 23:27:40 -05:00
|
|
|
#include <version.h>
|
|
|
|
#include <http.h>
|
|
|
|
#include <md5.h>
|
|
|
|
#include <update.h>
|
|
|
|
#include <hmap.h>
|
|
|
|
#include <air.h>
|
|
|
|
#include <icon.h>
|
2011-04-23 07:41:08 -05:00
|
|
|
#include <console.h>
|
2011-05-30 10:22:39 -05:00
|
|
|
#ifdef LUACONSOLE
|
|
|
|
#include "luaconsole.h"
|
|
|
|
#endif
|
2011-12-29 20:06:31 -06:00
|
|
|
#include "save.h"
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-05-28 15:01:31 -05:00
|
|
|
pixel *vid_buf;
|
2011-03-10 14:43:27 -06:00
|
|
|
|
2011-02-01 19:35:41 -06:00
|
|
|
#define NUM_SOUNDS 2
|
|
|
|
struct sample {
|
2011-02-03 12:45:56 -06:00
|
|
|
Uint8 *data;
|
|
|
|
Uint32 dpos;
|
|
|
|
Uint32 dlen;
|
2011-02-01 19:35:41 -06:00
|
|
|
} sounds[NUM_SOUNDS];
|
|
|
|
|
|
|
|
void mixaudio(void *unused, Uint8 *stream, int len)
|
|
|
|
{
|
2011-02-03 12:45:56 -06:00
|
|
|
int i;
|
|
|
|
Uint32 amount;
|
|
|
|
|
|
|
|
for ( i=0; i<NUM_SOUNDS; ++i ) {
|
|
|
|
amount = (sounds[i].dlen-sounds[i].dpos);
|
|
|
|
if ( amount > len ) {
|
|
|
|
amount = len;
|
|
|
|
}
|
|
|
|
SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME);
|
|
|
|
sounds[i].dpos += amount;
|
|
|
|
}
|
2011-02-01 19:35:41 -06:00
|
|
|
}
|
|
|
|
|
2011-03-30 12:57:49 -05:00
|
|
|
//plays a .wav file (sounds must be enabled)
|
2011-02-01 23:15:57 -06:00
|
|
|
void play_sound(char *file)
|
2011-02-01 19:35:41 -06:00
|
|
|
{
|
2011-02-03 12:45:56 -06:00
|
|
|
int index;
|
|
|
|
SDL_AudioSpec wave;
|
|
|
|
Uint8 *data;
|
|
|
|
Uint32 dlen;
|
|
|
|
SDL_AudioCVT cvt;
|
|
|
|
|
2011-02-08 08:30:02 -06:00
|
|
|
if (!sound_enable) return;
|
|
|
|
|
2011-02-03 12:45:56 -06:00
|
|
|
/* Look for an empty (or finished) sound slot */
|
|
|
|
for ( index=0; index<NUM_SOUNDS; ++index ) {
|
|
|
|
if ( sounds[index].dpos == sounds[index].dlen ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( index == NUM_SOUNDS )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Load the sound file and convert it to 16-bit stereo at 22kHz */
|
|
|
|
if ( SDL_LoadWAV(file, &wave, &data, &dlen) == NULL ) {
|
|
|
|
fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SDL_BuildAudioCVT(&cvt, wave.format, wave.channels, wave.freq,
|
|
|
|
AUDIO_S16, 2, 22050);
|
|
|
|
cvt.buf = malloc(dlen*cvt.len_mult);
|
|
|
|
memcpy(cvt.buf, data, dlen);
|
|
|
|
cvt.len = dlen;
|
|
|
|
SDL_ConvertAudio(&cvt);
|
|
|
|
SDL_FreeWAV(data);
|
|
|
|
|
|
|
|
/* Put the sound data in the slot (it starts playing immediately) */
|
|
|
|
if ( sounds[index].data ) {
|
|
|
|
free(sounds[index].data);
|
|
|
|
}
|
|
|
|
SDL_LockAudio();
|
|
|
|
sounds[index].data = cvt.buf;
|
|
|
|
sounds[index].dlen = cvt.len_cvt;
|
|
|
|
sounds[index].dpos = 0;
|
|
|
|
SDL_UnlockAudio();
|
2011-02-01 19:35:41 -06:00
|
|
|
}
|
|
|
|
|
2010-09-03 09:05:09 -05:00
|
|
|
static const char *it_msg =
|
2011-10-24 12:43:45 -05:00
|
|
|
"\blThe Powder Toy - Version " MTOS(SAVE_VERSION) "." MTOS(MINOR_VERSION) " - http://powdertoy.co.uk, irc.freenode.net #powder\n"
|
2010-08-26 06:38:24 -05:00
|
|
|
"\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\n"
|
|
|
|
"\n"
|
|
|
|
"\bgControl+C/V/X are Copy, Paste and cut respectively.\n"
|
2011-01-28 17:54:50 -06:00
|
|
|
"\bgTo choose a material, hover over one of the icons on the right, it will show a selection of elements in that group.\n"
|
2010-08-26 06:38:24 -05:00
|
|
|
"\bgPick your material from the menu using mouse left/right buttons.\n"
|
|
|
|
"Draw freeform lines by dragging your mouse left/right button across the drawing area.\n"
|
|
|
|
"Shift+drag will create straight lines of particles.\n"
|
|
|
|
"Ctrl+drag will result in filled rectangles.\n"
|
|
|
|
"Ctrl+Shift+click will flood-fill a closed area.\n"
|
|
|
|
"Ctrl+Z will act as Undo.\n"
|
|
|
|
"Middle click or Alt+Click to \"sample\" the particles.\n"
|
|
|
|
"\n\boUse 'Z' for a zoom tool. Click to make the drawable zoom window stay around. Use the wheel to change the zoom strength\n"
|
|
|
|
"Use 'S' to save parts of the window as 'stamps'.\n"
|
|
|
|
"'L' will load the most recent stamp, 'K' shows a library of stamps you saved.\n"
|
2011-01-28 17:54:50 -06:00
|
|
|
"'C' will cycle the display mode (Fire, Blob, Velocity, etc.). The numbers on the keyboard do the same\n"
|
2010-08-26 06:38:24 -05:00
|
|
|
"Use the mouse scroll wheel to change the tool size for particles.\n"
|
|
|
|
"The spacebar can be used to pause physics.\n"
|
|
|
|
"'P' will take a screenshot and save it into the current directory.\n"
|
|
|
|
"\n"
|
2011-09-03 08:06:36 -05:00
|
|
|
"Contributors: \bgStanislaw K Skowronek (\brhttp://powder.unaligned.org\bg, \bbirc.unaligned.org #wtf\bg),\n"
|
|
|
|
"\bgSimon Robertshaw, Skresanov Savely, cracker64, Catelite, Bryan Hoyle, Nathan Cousins, jacksonmj,\n"
|
2011-11-12 06:42:08 -06:00
|
|
|
"\bgLieuwe Mosch, Anthony Boot, Matthew \"me4502\", MaksProg\n"
|
2010-08-26 06:38:24 -05:00
|
|
|
"\n"
|
2012-03-23 05:41:29 -05:00
|
|
|
"\bgTo use online features such as saving, you need to register at: \brhttp://powdertoy.co.uk/Register.html\n"
|
|
|
|
"\n"
|
|
|
|
"\bt" MTOS(SAVE_VERSION) "." MTOS(MINOR_VERSION) "." MTOS(BUILD_NUM) " "
|
|
|
|
#ifdef X86
|
|
|
|
"X86 "
|
|
|
|
#endif
|
|
|
|
#ifdef X86_SSE
|
|
|
|
"X86_SSE "
|
|
|
|
#endif
|
|
|
|
#ifdef X86_SSE2
|
|
|
|
"X86_SSE2 "
|
|
|
|
#endif
|
|
|
|
#ifdef X86_SSE3
|
|
|
|
"X86_SSE3 "
|
|
|
|
#endif
|
|
|
|
#ifdef LIN32
|
|
|
|
"LIN32 "
|
|
|
|
#endif
|
|
|
|
#ifdef LIN64
|
|
|
|
"LIN64 "
|
|
|
|
#endif
|
|
|
|
#ifdef WIN32
|
|
|
|
"WIN32 "
|
|
|
|
#endif
|
|
|
|
#ifdef MACOSX
|
|
|
|
"MACOSX "
|
|
|
|
#endif
|
|
|
|
#ifdef LUACONSOLE
|
|
|
|
"LUACONSOLE "
|
|
|
|
#endif
|
|
|
|
#ifdef GRAVFFT
|
|
|
|
"GRAVFFT "
|
|
|
|
#endif
|
|
|
|
#ifdef REALISTIC
|
|
|
|
"REALISTIC"
|
|
|
|
#endif
|
2010-08-26 06:38:24 -05:00
|
|
|
;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
int start, inc;
|
|
|
|
pixel *vid;
|
2010-08-26 06:38:24 -05:00
|
|
|
} upstruc;
|
|
|
|
|
2011-08-19 17:44:09 -05:00
|
|
|
static const char *old_ver_msg_beta = "A new beta is available - click here!";
|
|
|
|
static const char *old_ver_msg = "A new version is available - click here!";
|
2011-05-16 06:46:08 -05:00
|
|
|
char new_message_msg[255];
|
2010-08-26 06:38:24 -05:00
|
|
|
float mheat = 0.0f;
|
|
|
|
|
|
|
|
int do_open = 0;
|
|
|
|
int sys_pause = 0;
|
2011-03-10 14:43:27 -06:00
|
|
|
int sys_shortcuts = 1;
|
2011-04-25 10:39:28 -05:00
|
|
|
int legacy_enable = 0; //Used to disable new features such as heat, will be set by save.
|
2011-06-01 14:18:19 -05:00
|
|
|
int aheat_enable; //Ambient heat
|
2011-05-21 07:27:19 -05:00
|
|
|
int decorations_enable = 1;
|
2011-07-22 09:08:13 -05:00
|
|
|
int hud_enable = 1;
|
|
|
|
int active_menu = 0;
|
2011-07-14 04:37:34 -05:00
|
|
|
int framerender = 0;
|
2011-10-09 07:55:16 -05:00
|
|
|
int pretty_powder = 0;
|
2010-08-26 06:38:24 -05:00
|
|
|
int amd = 1;
|
2010-09-06 21:41:51 -05:00
|
|
|
int FPSB = 0;
|
2010-11-01 22:56:06 -05:00
|
|
|
int MSIGN =-1;
|
2011-04-12 06:19:21 -05:00
|
|
|
int frameidx = 0;
|
2010-11-12 11:46:02 -06:00
|
|
|
//int CGOL = 0;
|
|
|
|
//int GSPEED = 1;//causes my .exe to crash..
|
2011-02-21 10:24:03 -06:00
|
|
|
int sound_enable = 0;
|
2011-04-23 07:41:08 -05:00
|
|
|
|
2011-10-16 18:16:43 -05:00
|
|
|
int debug_flags = 0;
|
|
|
|
int debug_perf_istart = 1;
|
|
|
|
int debug_perf_iend = 0;
|
|
|
|
long debug_perf_frametime[DEBUG_PERF_FRAMECOUNT];
|
|
|
|
long debug_perf_partitime[DEBUG_PERF_FRAMECOUNT];
|
|
|
|
long debug_perf_time = 0;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2010-08-27 07:01:20 -05:00
|
|
|
sign signs[MAXSIGNS];
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2010-08-26 08:46:56 -05:00
|
|
|
int numCores = 4;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2010-08-26 08:46:56 -05:00
|
|
|
int core_count()
|
2010-08-26 06:38:24 -05:00
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
int numCPU = 1;
|
2010-08-26 06:38:24 -05:00
|
|
|
#ifdef MT
|
2010-08-26 08:46:56 -05:00
|
|
|
#ifdef WIN32
|
2011-01-28 17:54:50 -06:00
|
|
|
SYSTEM_INFO sysinfo;
|
|
|
|
GetSystemInfo( &sysinfo );
|
|
|
|
numCPU = sysinfo.dwNumberOfProcessors;
|
2010-08-26 08:46:56 -05:00
|
|
|
#else
|
|
|
|
#ifdef MACOSX
|
2011-01-28 17:54:50 -06:00
|
|
|
numCPU = 4;
|
2010-08-26 08:46:56 -05:00
|
|
|
#else
|
2011-01-28 17:54:50 -06:00
|
|
|
numCPU = sysconf( _SC_NPROCESSORS_ONLN );
|
2010-08-26 08:46:56 -05:00
|
|
|
#endif
|
2010-08-26 06:38:24 -05:00
|
|
|
#endif
|
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
printf("Cpus: %d\n", numCPU);
|
|
|
|
if (numCPU>1)
|
|
|
|
printf("Multithreading enabled\n");
|
|
|
|
else
|
|
|
|
printf("Multithreading disabled\n");
|
2010-08-26 06:38:24 -05:00
|
|
|
#endif
|
2011-01-28 17:54:50 -06:00
|
|
|
return numCPU;
|
2010-08-26 08:46:56 -05:00
|
|
|
}
|
|
|
|
|
2010-09-03 09:05:09 -05:00
|
|
|
int mousex = 0, mousey = 0; //They contain mouse position
|
2011-01-08 20:23:46 -06:00
|
|
|
int kiosk_enable = 0;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
|
|
|
void sdl_seticon(void)
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
2011-01-28 17:54:50 -06:00
|
|
|
//SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
|
|
|
//SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/);
|
2010-08-26 06:38:24 -05:00
|
|
|
#else
|
|
|
|
#ifdef MACOSX
|
2011-01-28 17:54:50 -06:00
|
|
|
//SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon_w32, 32, 32, 32, 128, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
|
|
|
//SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/);
|
2010-09-02 18:06:18 -05:00
|
|
|
#else
|
2011-03-17 17:05:09 -05:00
|
|
|
SDL_Surface *icon = SDL_CreateRGBSurfaceFrom(app_icon, 16, 16, 32, 64, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
2011-01-28 17:54:50 -06:00
|
|
|
SDL_WM_SetIcon(icon, NULL/*app_icon_mask*/);
|
2010-08-26 06:38:24 -05:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int frame_idx=0;
|
|
|
|
void dump_frame(pixel *src, int w, int h, int pitch)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
char frame_name[32];
|
|
|
|
int j,i;
|
|
|
|
unsigned char c[3];
|
|
|
|
FILE *f;
|
|
|
|
sprintf(frame_name,"frame%04d.ppm",frame_idx);
|
|
|
|
f=fopen(frame_name,"wb");
|
|
|
|
fprintf(f,"P6\n%d %d\n255\n",w,h);
|
|
|
|
for (j=0; j<h; j++)
|
|
|
|
{
|
|
|
|
for (i=0; i<w; i++)
|
|
|
|
{
|
|
|
|
c[0] = PIXR(src[i]);
|
|
|
|
c[1] = PIXG(src[i]);
|
|
|
|
c[2] = PIXB(src[i]);
|
|
|
|
fwrite(c,3,1,f);
|
|
|
|
}
|
|
|
|
src+=pitch;
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
frame_idx++;
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************
|
|
|
|
* STATE MANAGEMENT *
|
|
|
|
***********************************************************/
|
|
|
|
|
2011-02-19 09:34:04 -06:00
|
|
|
void clear_sim(void)
|
|
|
|
{
|
2011-12-13 03:16:17 -06:00
|
|
|
int i, x, y;
|
2011-02-19 09:34:04 -06:00
|
|
|
memset(bmap, 0, sizeof(bmap));
|
|
|
|
memset(emap, 0, sizeof(emap));
|
|
|
|
memset(signs, 0, sizeof(signs));
|
2012-02-11 05:12:53 -06:00
|
|
|
MSIGN = -1;
|
2011-02-19 09:34:04 -06:00
|
|
|
memset(parts, 0, sizeof(particle)*NPART);
|
2011-12-13 03:16:17 -06:00
|
|
|
for (i=0; i<NPART-1; i++)
|
|
|
|
parts[i].life = i+1;
|
|
|
|
parts[NPART-1].life = -1;
|
|
|
|
pfree = 0;
|
|
|
|
parts_lastActiveIndex = 0;
|
2011-02-19 09:34:04 -06:00
|
|
|
memset(pmap, 0, sizeof(pmap));
|
|
|
|
memset(pv, 0, sizeof(pv));
|
|
|
|
memset(vx, 0, sizeof(vx));
|
|
|
|
memset(vy, 0, sizeof(vy));
|
|
|
|
memset(fvx, 0, sizeof(fvx));
|
|
|
|
memset(fvy, 0, sizeof(fvy));
|
|
|
|
memset(photons, 0, sizeof(photons));
|
|
|
|
memset(wireless, 0, sizeof(wireless));
|
|
|
|
memset(gol2, 0, sizeof(gol2));
|
2011-04-25 12:05:35 -05:00
|
|
|
memset(portalp, 0, sizeof(portalp));
|
2011-08-29 11:47:22 -05:00
|
|
|
memset(fighters, 0, sizeof(fighters));
|
|
|
|
fighcount = 0;
|
2011-07-14 04:37:34 -05:00
|
|
|
ISSPAWN1 = ISSPAWN2 = 0;
|
2011-10-23 03:22:31 -05:00
|
|
|
player.spwn = 0;
|
|
|
|
player2.spwn = 0;
|
2011-02-19 09:34:04 -06:00
|
|
|
memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
|
|
|
memset(fire_r, 0, sizeof(fire_r));
|
|
|
|
memset(fire_g, 0, sizeof(fire_g));
|
|
|
|
memset(fire_b, 0, sizeof(fire_b));
|
2011-12-24 12:22:58 -06:00
|
|
|
if(gravmask)
|
|
|
|
memset(gravmask, 0xFFFFFFFF, (XRES/CELL)*(YRES/CELL)*sizeof(unsigned));
|
|
|
|
if(gravy)
|
|
|
|
memset(gravy, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
|
|
|
|
if(gravx)
|
|
|
|
memset(gravx, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
|
|
|
|
if(gravp)
|
|
|
|
memset(gravp, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float));
|
2011-06-09 16:35:00 -05:00
|
|
|
for(x = 0; x < XRES/CELL; x++){
|
|
|
|
for(y = 0; y < YRES/CELL; y++){
|
|
|
|
hv[y][x] = 273.15f+22.0f; //Set to room temperature
|
|
|
|
}
|
|
|
|
}
|
2011-02-19 09:34:04 -06:00
|
|
|
}
|
|
|
|
|
2010-08-26 06:38:24 -05:00
|
|
|
// stamps library
|
|
|
|
|
2010-08-28 05:40:49 -05:00
|
|
|
stamp stamps[STAMP_MAX];//[STAMP_X*STAMP_Y];
|
2010-08-26 06:38:24 -05:00
|
|
|
|
|
|
|
int stamp_count = 0;
|
|
|
|
|
|
|
|
unsigned last_time=0, last_name=0;
|
|
|
|
void stamp_gen_name(char *fn)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
unsigned t=(unsigned)time(NULL);
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
if (last_time!=t)
|
|
|
|
{
|
|
|
|
last_time=t;
|
|
|
|
last_name=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
last_name++;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
sprintf(fn, "%08x%02x", last_time, last_name);
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void stamp_update(void)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
FILE *f;
|
|
|
|
int i;
|
|
|
|
f=fopen("stamps" PATH_SEP "stamps.def", "wb");
|
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
for (i=0; i<STAMP_MAX; i++)
|
|
|
|
{
|
|
|
|
if (!stamps[i].name[0])
|
|
|
|
break;
|
|
|
|
if (stamps[i].dodelete!=1)
|
|
|
|
{
|
|
|
|
fwrite(stamps[i].name, 1, 10, f);
|
|
|
|
}
|
2012-01-17 19:51:16 -06:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char name[30] = {0};
|
|
|
|
sprintf(name,"stamps%s%s.stm",PATH_SEP,stamps[i].name);
|
|
|
|
remove(name);
|
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
fclose(f);
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void stamp_gen_thumb(int i)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
char fn[64];
|
|
|
|
void *data;
|
|
|
|
int size, factor_x, factor_y;
|
|
|
|
pixel *tmp;
|
|
|
|
|
|
|
|
if (stamps[i].thumb)
|
|
|
|
{
|
|
|
|
free(stamps[i].thumb);
|
|
|
|
stamps[i].thumb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(fn, "stamps" PATH_SEP "%s.stm", stamps[i].name);
|
|
|
|
data = file_load(fn, &size);
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
stamps[i].thumb = prerender_save(data, size, &(stamps[i].thumb_w), &(stamps[i].thumb_h));
|
|
|
|
if (stamps[i].thumb && (stamps[i].thumb_w>XRES/GRID_S || stamps[i].thumb_h>YRES/GRID_S))
|
|
|
|
{
|
|
|
|
factor_x = ceil((float)stamps[i].thumb_w/(float)(XRES/GRID_S));
|
|
|
|
factor_y = ceil((float)stamps[i].thumb_h/(float)(YRES/GRID_S));
|
|
|
|
if (factor_y > factor_x)
|
|
|
|
factor_x = factor_y;
|
|
|
|
tmp = rescale_img(stamps[i].thumb, stamps[i].thumb_w, stamps[i].thumb_h, &(stamps[i].thumb_w), &(stamps[i].thumb_h), factor_x);
|
|
|
|
free(stamps[i].thumb);
|
|
|
|
stamps[i].thumb = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free(data);
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int clipboard_ready = 0;
|
|
|
|
void *clipboard_data = 0;
|
|
|
|
int clipboard_length = 0;
|
|
|
|
|
|
|
|
void stamp_save(int x, int y, int w, int h)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
FILE *f;
|
|
|
|
int n;
|
|
|
|
char fn[64], sn[16];
|
2011-12-29 20:06:31 -06:00
|
|
|
void *s=build_save(&n, x, y, w, h, bmap, vx, vy, pv, fvx, fvy, signs, parts);
|
2012-01-19 17:19:39 -06:00
|
|
|
if (!s)
|
|
|
|
return;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
|
|
|
#ifdef WIN32
|
2011-01-28 17:54:50 -06:00
|
|
|
_mkdir("stamps");
|
2010-08-26 06:38:24 -05:00
|
|
|
#else
|
2011-01-28 17:54:50 -06:00
|
|
|
mkdir("stamps", 0755);
|
2010-08-26 06:38:24 -05:00
|
|
|
#endif
|
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
stamp_gen_name(sn);
|
|
|
|
sprintf(fn, "stamps" PATH_SEP "%s.stm", sn);
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
f = fopen(fn, "wb");
|
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
fwrite(s, n, 1, f);
|
|
|
|
fclose(f);
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
free(s);
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
if (stamps[STAMP_MAX-1].thumb)
|
|
|
|
free(stamps[STAMP_MAX-1].thumb);
|
|
|
|
memmove(stamps+1, stamps, sizeof(struct stamp)*(STAMP_MAX-1));
|
|
|
|
memset(stamps, 0, sizeof(struct stamp));
|
|
|
|
if (stamp_count<STAMP_MAX)
|
|
|
|
stamp_count++;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
strcpy(stamps[0].name, sn);
|
|
|
|
stamp_gen_thumb(0);
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
stamp_update();
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void *stamp_load(int i, int *size)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
void *data;
|
|
|
|
char fn[64];
|
|
|
|
struct stamp tmp;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
if (!stamps[i].thumb || !stamps[i].name[0])
|
|
|
|
return NULL;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
sprintf(fn, "stamps" PATH_SEP "%s.stm", stamps[i].name);
|
|
|
|
data = file_load(fn, size);
|
|
|
|
if (!data)
|
|
|
|
return NULL;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
if (i>0)
|
|
|
|
{
|
|
|
|
memcpy(&tmp, stamps+i, sizeof(struct stamp));
|
|
|
|
memmove(stamps+1, stamps, sizeof(struct stamp)*i);
|
|
|
|
memcpy(stamps, &tmp, sizeof(struct stamp));
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
stamp_update();
|
|
|
|
}
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-01-28 17:54:50 -06:00
|
|
|
return data;
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void stamp_init(void)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
int i;
|
|
|
|
FILE *f;
|
|
|
|
|
|
|
|
memset(stamps, 0, sizeof(stamps));
|
|
|
|
|
|
|
|
f=fopen("stamps" PATH_SEP "stamps.def", "rb");
|
|
|
|
if (!f)
|
|
|
|
return;
|
|
|
|
for (i=0; i<STAMP_MAX; i++)
|
|
|
|
{
|
|
|
|
fread(stamps[i].name, 1, 10, f);
|
|
|
|
if (!stamps[i].name[0])
|
|
|
|
break;
|
|
|
|
stamp_count++;
|
|
|
|
stamp_gen_thumb(i);
|
|
|
|
}
|
|
|
|
fclose(f);
|
2010-08-28 05:40:49 -05:00
|
|
|
}
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2010-08-28 05:40:49 -05:00
|
|
|
void del_stamp(int d)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
stamps[d].dodelete = 1;
|
|
|
|
stamp_update();
|
|
|
|
stamp_count = 0;
|
|
|
|
stamp_init();
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void thumb_cache_inval(char *id);
|
|
|
|
|
|
|
|
char *thumb_cache_id[THUMB_CACHE_SIZE];
|
|
|
|
void *thumb_cache_data[THUMB_CACHE_SIZE];
|
|
|
|
int thumb_cache_size[THUMB_CACHE_SIZE];
|
|
|
|
int thumb_cache_lru[THUMB_CACHE_SIZE];
|
|
|
|
|
|
|
|
void thumb_cache_inval(char *id)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
int i,j;
|
|
|
|
for (i=0; i<THUMB_CACHE_SIZE; i++)
|
|
|
|
if (thumb_cache_id[i] && !strcmp(id, thumb_cache_id[i]))
|
|
|
|
break;
|
|
|
|
if (i >= THUMB_CACHE_SIZE)
|
|
|
|
return;
|
|
|
|
free(thumb_cache_id[i]);
|
|
|
|
free(thumb_cache_data[i]);
|
|
|
|
thumb_cache_id[i] = NULL;
|
|
|
|
for (j=0; j<THUMB_CACHE_SIZE; j++)
|
|
|
|
if (thumb_cache_lru[j] > thumb_cache_lru[i])
|
|
|
|
thumb_cache_lru[j]--;
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
void thumb_cache_add(char *id, void *thumb, int size)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
int i,m=-1,j=-1;
|
|
|
|
thumb_cache_inval(id);
|
|
|
|
for (i=0; i<THUMB_CACHE_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (!thumb_cache_id[i])
|
|
|
|
break;
|
|
|
|
if (thumb_cache_lru[i] > m)
|
|
|
|
{
|
|
|
|
m = thumb_cache_lru[i];
|
|
|
|
j = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i >= THUMB_CACHE_SIZE)
|
|
|
|
{
|
|
|
|
thumb_cache_inval(thumb_cache_id[j]);
|
|
|
|
i = j;
|
|
|
|
}
|
|
|
|
for (j=0; j<THUMB_CACHE_SIZE; j++)
|
|
|
|
thumb_cache_lru[j] ++;
|
|
|
|
thumb_cache_id[i] = mystrdup(id);
|
|
|
|
thumb_cache_data[i] = malloc(size);
|
|
|
|
memcpy(thumb_cache_data[i], thumb, size);
|
|
|
|
thumb_cache_size[i] = size;
|
|
|
|
thumb_cache_lru[i] = 0;
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
int thumb_cache_find(char *id, void **thumb, int *size)
|
|
|
|
{
|
2011-01-28 17:54:50 -06:00
|
|
|
int i,j;
|
|
|
|
for (i=0; i<THUMB_CACHE_SIZE; i++)
|
|
|
|
if (thumb_cache_id[i] && !strcmp(id, thumb_cache_id[i]))
|
|
|
|
break;
|
|
|
|
if (i >= THUMB_CACHE_SIZE)
|
|
|
|
return 0;
|
|
|
|
for (j=0; j<THUMB_CACHE_SIZE; j++)
|
|
|
|
if (thumb_cache_lru[j] < thumb_cache_lru[i])
|
|
|
|
thumb_cache_lru[j]++;
|
|
|
|
thumb_cache_lru[i] = 0;
|
|
|
|
*thumb = malloc(thumb_cache_size[i]);
|
|
|
|
*size = thumb_cache_size[i];
|
|
|
|
memcpy(*thumb, thumb_cache_data[i], *size);
|
|
|
|
return 1;
|
2010-08-26 06:38:24 -05:00
|
|
|
}
|
|
|
|
|
2010-08-29 07:10:58 -05:00
|
|
|
char http_proxy_string[256] = "";
|
2010-08-26 06:38:24 -05:00
|
|
|
|
2011-09-24 10:57:01 -05:00
|
|
|
unsigned char last_major=0, last_minor=0, last_build=0, update_flag=0;
|
2010-08-26 06:38:24 -05:00
|
|
|
|
|
|
|
char *tag = "(c) 2008-9 Stanislaw Skowronek";
|
|
|
|
int itc = 0;
|
|
|
|
char itc_msg[64] = "[?]";
|
|
|
|
|
2011-08-19 17:44:09 -05:00
|
|
|
char my_uri[] = "http://" SERVER "/Update.api?Action=Download&Architecture="
|
|
|
|
#if defined WIN32
|
|
|
|
"Windows32"
|
|
|
|
#elif defined LIN32
|
|
|
|
"Linux32"
|
|
|
|
#elif defined LIN64
|
|
|
|
"Linux64"
|
|
|
|
#elif defined MACOSX
|
|
|
|
"MacOSX"
|
|
|
|
#else
|
|
|
|
"Unknown"
|
|
|
|
#endif
|
|
|
|
"&InstructionSet="
|
|
|
|
#if defined X86_SSE3
|
|
|
|
"SSE3"
|
|
|
|
#elif defined X86_SSE2
|
|
|
|
"SSE2"
|
|
|
|
#elif defined X86_SSE
|
|
|
|
"SSE"
|
|
|
|
#else
|
|
|
|
"SSE"
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2011-05-24 08:54:14 -05:00
|
|
|
int set_scale(int scale, int kiosk){
|
|
|
|
int old_scale = sdl_scale, old_kiosk = kiosk_enable;
|
2011-05-13 04:44:39 -05:00
|
|
|
sdl_scale = scale;
|
2011-05-15 14:40:08 -05:00
|
|
|
kiosk_enable = kiosk;
|
2011-05-24 08:54:14 -05:00
|
|
|
if (!sdl_open())
|
|
|
|
{
|
|
|
|
sdl_scale = old_scale;
|
|
|
|
kiosk_enable = old_kiosk;
|
|
|
|
sdl_open();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
2011-05-13 04:44:39 -05:00
|
|
|
}
|
2011-05-12 12:04:29 -05:00
|
|
|
|
2011-04-12 06:19:21 -05:00
|
|
|
#ifdef RENDERER
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-04-12 06:39:28 -05:00
|
|
|
pixel *vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
2011-04-12 06:19:21 -05:00
|
|
|
int load_size, i=0, j=0;
|
|
|
|
void *load_data = file_load(argv[1], &load_size);
|
|
|
|
unsigned char c[3];
|
2011-05-28 08:57:07 -05:00
|
|
|
char ppmfilename[256], ptifilename[256], ptismallfilename[256];
|
2011-04-12 06:19:21 -05:00
|
|
|
FILE *f;
|
|
|
|
|
2011-11-12 14:44:15 -06:00
|
|
|
colour_mode = COLOUR_DEFAULT;
|
|
|
|
init_display_modes();
|
2012-04-27 11:59:24 -05:00
|
|
|
TRON_init_graphics();
|
2011-11-12 14:44:15 -06:00
|
|
|
|
2011-04-12 06:19:21 -05:00
|
|
|
sys_pause = 1;
|
|
|
|
parts = calloc(sizeof(particle), NPART);
|
|
|
|
for (i=0; i<NPART-1; i++)
|
|
|
|
parts[i].life = i+1;
|
|
|
|
parts[NPART-1].life = -1;
|
|
|
|
pfree = 0;
|
2011-05-28 15:24:07 -05:00
|
|
|
|
2011-04-12 06:39:28 -05:00
|
|
|
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
2011-04-12 06:19:21 -05:00
|
|
|
|
2011-12-24 12:22:58 -06:00
|
|
|
prepare_alpha(CELL, 1.0f);
|
|
|
|
prepare_graphicscache();
|
|
|
|
flm_data = generate_gradient(flm_data_colours, flm_data_pos, flm_data_points, 200);
|
|
|
|
plasma_data = generate_gradient(plasma_data_colours, plasma_data_pos, plasma_data_points, 200);
|
|
|
|
|
2011-10-23 03:22:31 -05:00
|
|
|
player.elem = player2.elem = PT_DUST;
|
|
|
|
player.frames = player2.frames = 0;
|
2011-05-28 08:57:07 -05:00
|
|
|
|
|
|
|
sprintf(ppmfilename, "%s.ppm", argv[2]);
|
|
|
|
sprintf(ptifilename, "%s.pti", argv[2]);
|
|
|
|
sprintf(ptismallfilename, "%s-small.pti", argv[2]);
|
2011-04-12 06:19:21 -05:00
|
|
|
|
|
|
|
if(load_data && load_size){
|
|
|
|
int parsestate = 0;
|
2011-05-28 15:01:31 -05:00
|
|
|
//parsestate = parse_save(load_data, load_size, 1, 0, 0);
|
2011-12-29 20:06:31 -06:00
|
|
|
parsestate = parse_save(load_data, load_size, 1, 0, 0, bmap, vx, vy, pv, fvx, fvy, signs, parts, pmap);
|
2011-04-12 06:19:21 -05:00
|
|
|
|
|
|
|
for(i=0; i<30; i++){
|
2011-04-12 06:39:28 -05:00
|
|
|
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
2011-05-14 07:28:02 -05:00
|
|
|
draw_walls(vid_buf);
|
2011-04-12 06:19:21 -05:00
|
|
|
update_particles(vid_buf);
|
2011-10-10 14:42:55 -05:00
|
|
|
render_parts(vid_buf);
|
2011-04-12 06:19:21 -05:00
|
|
|
render_fire(vid_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
render_signs(vid_buf);
|
|
|
|
|
|
|
|
if(parsestate>0){
|
|
|
|
//return 0;
|
|
|
|
info_box(vid_buf, "Save file invalid or from newer version");
|
|
|
|
}
|
2011-05-28 07:49:07 -05:00
|
|
|
|
2011-05-28 08:57:07 -05:00
|
|
|
//Save PTi images
|
|
|
|
char * datares = NULL, *scaled_buf;
|
|
|
|
int res = 0, sw, sh;
|
|
|
|
datares = ptif_pack(vid_buf, XRES, YRES, &res);
|
|
|
|
if(datares!=NULL){
|
|
|
|
f=fopen(ptifilename, "wb");
|
|
|
|
fwrite(datares, res, 1, f);
|
|
|
|
fclose(f);
|
|
|
|
free(datares);
|
|
|
|
datares = NULL;
|
|
|
|
}
|
2011-06-08 07:30:39 -05:00
|
|
|
scaled_buf = resample_img(vid_buf, XRES, YRES, XRES/GRID_Z, YRES/GRID_Z);
|
|
|
|
datares = ptif_pack(scaled_buf, XRES/GRID_Z, YRES/GRID_Z, &res);
|
2011-05-28 08:57:07 -05:00
|
|
|
if(datares!=NULL){
|
|
|
|
f=fopen(ptismallfilename, "wb");
|
|
|
|
fwrite(datares, res, 1, f);
|
|
|
|
fclose(f);
|
|
|
|
free(datares);
|
|
|
|
datares = NULL;
|
|
|
|
}
|
|
|
|
free(scaled_buf);
|
|
|
|
//Save PPM image
|
|
|
|
f=fopen(ppmfilename, "wb");
|
|
|
|
fprintf(f,"P6\n%d %d\n255\n",XRES,YRES);
|
|
|
|
for (j=0; j<YRES; j++)
|
|
|
|
{
|
|
|
|
for (i=0; i<XRES; i++)
|
2011-04-12 06:19:21 -05:00
|
|
|
{
|
2011-05-28 08:57:07 -05:00
|
|
|
c[0] = PIXR(vid_buf[i]);
|
|
|
|
c[1] = PIXG(vid_buf[i]);
|
|
|
|
c[2] = PIXB(vid_buf[i]);
|
|
|
|
fwrite(c,3,1,f);
|
2011-04-12 06:19:21 -05:00
|
|
|
}
|
2011-05-28 08:57:07 -05:00
|
|
|
vid_buf+=XRES+BARSIZE;
|
2011-04-12 06:19:21 -05:00
|
|
|
}
|
2011-05-28 08:57:07 -05:00
|
|
|
fclose(f);
|
2011-04-12 06:19:21 -05:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
2011-04-08 09:28:57 -05:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2011-07-18 17:58:08 -05:00
|
|
|
pixel *part_vbuf; //Extra video buffer
|
|
|
|
pixel *part_vbuf_store;
|
2011-04-08 09:28:57 -05:00
|
|
|
char uitext[512] = "";
|
|
|
|
char heattext[256] = "";
|
|
|
|
char coordtext[128] = "";
|
|
|
|
int currentTime = 0;
|
2011-08-16 11:45:44 -05:00
|
|
|
int FPS = 0, pastFPS = 0, elapsedTime = 0;
|
2011-04-24 11:49:33 -05:00
|
|
|
void *http_ver_check, *http_session_check = NULL;
|
2011-08-19 17:44:09 -05:00
|
|
|
char *ver_data=NULL, *check_data=NULL, *tmp;
|
2011-04-08 09:28:57 -05:00
|
|
|
//char console_error[255] = "";
|
2011-10-23 12:37:25 -05:00
|
|
|
int result, i, j, bq, bc = 0, fire_fc=0, do_check=0, do_s_check=0, old_version=0, http_ret=0,http_s_ret=0, major, minor, buildnum, is_beta = 0, old_ver_len, new_message_len=0;
|
2011-04-08 09:28:57 -05:00
|
|
|
#ifdef INTERNAL
|
|
|
|
int vs = 0;
|
|
|
|
#endif
|
|
|
|
int wavelength_gfx = 0;
|
2011-07-12 03:35:55 -05:00
|
|
|
int x, y, line_x, line_y, b = 0, sl=1, sr=0, su=0, c, lb = 0, lx = 0, ly = 0, lm = 0;//, tx, ty;
|
2011-10-24 12:43:45 -05:00
|
|
|
int da = 0, dae = 0, db = 0, it = 2047, mx, my, bsx = 2, bsy = 2, quickoptions_tooltip_fade_invert, it_invert = 0;
|
2011-04-08 09:28:57 -05:00
|
|
|
float nfvx, nfvy;
|
|
|
|
int load_mode=0, load_w=0, load_h=0, load_x=0, load_y=0, load_size=0;
|
|
|
|
void *load_data=NULL;
|
|
|
|
pixel *load_img=NULL;//, *fbi_img=NULL;
|
|
|
|
int save_mode=0, save_x=0, save_y=0, save_w=0, save_h=0, copy_mode=0;
|
2011-09-19 11:31:14 -05:00
|
|
|
unsigned int rgbSave = PIXRGB(127,0,0);
|
2011-04-08 09:28:57 -05:00
|
|
|
SDL_AudioSpec fmt;
|
|
|
|
int username_flash = 0, username_flash_t = 1;
|
2011-05-19 09:32:50 -05:00
|
|
|
#ifdef PTW32_STATIC_LIB
|
|
|
|
pthread_win32_process_attach_np();
|
|
|
|
pthread_win32_thread_attach_np();
|
2011-04-08 09:28:57 -05:00
|
|
|
#endif
|
2011-09-02 17:24:29 -05:00
|
|
|
limitFPS = 60;
|
2011-04-08 09:28:57 -05:00
|
|
|
vid_buf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
2011-07-18 17:58:08 -05:00
|
|
|
part_vbuf = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); //Extra video buffer
|
|
|
|
part_vbuf_store = part_vbuf;
|
2011-04-08 09:28:57 -05:00
|
|
|
pers_bg = calloc((XRES+BARSIZE)*YRES, PIXELSIZE);
|
2011-07-18 17:58:08 -05:00
|
|
|
|
2011-12-10 09:23:33 -06:00
|
|
|
gravity_init();
|
2011-04-08 09:28:57 -05:00
|
|
|
GSPEED = 1;
|
2011-04-08 05:09:42 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
/* Set 16-bit stereo audio at 22Khz */
|
|
|
|
fmt.freq = 22050;
|
|
|
|
fmt.format = AUDIO_S16;
|
|
|
|
fmt.channels = 2;
|
|
|
|
fmt.samples = 512;
|
|
|
|
fmt.callback = mixaudio;
|
|
|
|
fmt.userdata = NULL;
|
2011-04-08 05:09:42 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
#ifdef MT
|
|
|
|
numCores = core_count();
|
2011-08-19 17:44:09 -05:00
|
|
|
#endif
|
|
|
|
//TODO: Move out version stuff
|
2011-04-08 09:28:57 -05:00
|
|
|
menu_count();
|
|
|
|
parts = calloc(sizeof(particle), NPART);
|
|
|
|
cb_parts = calloc(sizeof(particle), NPART);
|
2011-05-28 17:15:29 -05:00
|
|
|
init_can_move();
|
2011-04-08 09:28:57 -05:00
|
|
|
clear_sim();
|
2011-11-12 14:44:15 -06:00
|
|
|
|
2011-12-17 15:30:00 -06:00
|
|
|
#ifdef LUACONSOLE
|
|
|
|
luacon_open();
|
|
|
|
#endif
|
|
|
|
|
2011-11-12 14:44:15 -06:00
|
|
|
colour_mode = COLOUR_DEFAULT;
|
|
|
|
init_display_modes();
|
2012-04-27 11:59:24 -05:00
|
|
|
TRON_init_graphics();
|
2011-04-08 09:28:57 -05:00
|
|
|
|
|
|
|
//fbi_img = render_packed_rgb(fbi, FBI_W, FBI_H, FBI_CMP);
|
|
|
|
|
2011-09-24 10:57:01 -05:00
|
|
|
for (i=1; i<argc; i++)
|
|
|
|
{
|
|
|
|
if (!strncmp(argv[i], "ddir", 4) && i+1<argc)
|
|
|
|
{
|
|
|
|
chdir(argv[i+1]);
|
|
|
|
i++;
|
|
|
|
}
|
2011-09-27 08:17:36 -05:00
|
|
|
else if (!strncmp(argv[i], "open", 4) && i+1<argc)
|
|
|
|
{
|
|
|
|
int size;
|
|
|
|
void *file_data;
|
|
|
|
file_data = file_load(argv[i+1], &size);
|
|
|
|
if (file_data)
|
|
|
|
{
|
|
|
|
svf_last = file_data;
|
|
|
|
svf_lsize = size;
|
2011-12-29 20:06:31 -06:00
|
|
|
if(!parse_save(file_data, size, 1, 0, 0, bmap, fvx, fvy, vx, vy, pv, signs, parts, pmap))
|
2011-09-27 08:17:36 -05:00
|
|
|
{
|
|
|
|
it=0;
|
|
|
|
svf_filename[0] = 0;
|
|
|
|
svf_fileopen = 1;
|
|
|
|
} else {
|
|
|
|
svf_last = NULL;
|
|
|
|
svf_lsize = 0;
|
|
|
|
free(file_data);
|
|
|
|
file_data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2011-09-24 10:57:01 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
load_presets();
|
|
|
|
|
|
|
|
for (i=1; i<argc; i++)
|
|
|
|
{
|
|
|
|
if (!strncmp(argv[i], "scale:", 6))
|
|
|
|
{
|
|
|
|
sdl_scale = (argv[i][6]=='2') ? 2 : 1;
|
|
|
|
}
|
|
|
|
else if (!strncmp(argv[i], "proxy:", 6))
|
|
|
|
{
|
|
|
|
memset(http_proxy_string, 0, sizeof(http_proxy_string));
|
|
|
|
strncpy(http_proxy_string, argv[i]+6, 255);
|
|
|
|
}
|
|
|
|
else if (!strncmp(argv[i], "nohud", 5))
|
|
|
|
{
|
|
|
|
hud_enable = 0;
|
|
|
|
}
|
|
|
|
else if (!strncmp(argv[i], "kiosk", 5))
|
|
|
|
{
|
|
|
|
kiosk_enable = 1;
|
|
|
|
//sdl_scale = 2; //Removed because some displays cannot handle the resolution
|
|
|
|
hud_enable = 0;
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (!strncmp(argv[i], "sound", 5))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
/* Open the audio device and start playing sound! */
|
|
|
|
if ( SDL_OpenAudio(&fmt, NULL) < 0 )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
sound_enable = 1;
|
|
|
|
SDL_PauseAudio(0);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (!strncmp(argv[i], "scripts", 5))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
file_script = 1;
|
|
|
|
}
|
|
|
|
else if (!strncmp(argv[i], "open", 4) && i+1<argc)
|
|
|
|
{
|
2011-08-19 06:28:09 -05:00
|
|
|
i++;
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
2011-09-19 14:05:15 -05:00
|
|
|
else if (!strncmp(argv[i], "ddir", 4) && i+1<argc)
|
|
|
|
{
|
2011-09-24 10:57:01 -05:00
|
|
|
i++;
|
2011-09-19 14:05:15 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
make_kernel();
|
|
|
|
|
|
|
|
stamp_init();
|
|
|
|
|
2011-08-30 04:26:42 -05:00
|
|
|
if (!sdl_open())
|
|
|
|
{
|
|
|
|
sdl_scale = 1;
|
|
|
|
kiosk_enable = 0;
|
|
|
|
if (!sdl_open()) exit(1);
|
|
|
|
}
|
|
|
|
save_presets(0);
|
2011-04-08 09:28:57 -05:00
|
|
|
http_init(http_proxy_string[0] ? http_proxy_string : NULL);
|
|
|
|
|
2011-10-19 18:34:31 -05:00
|
|
|
prepare_alpha(CELL, 1.0f);
|
2011-10-23 07:52:26 -05:00
|
|
|
prepare_graphicscache();
|
2011-10-24 11:20:18 -05:00
|
|
|
flm_data = generate_gradient(flm_data_colours, flm_data_pos, flm_data_points, 200);
|
|
|
|
plasma_data = generate_gradient(plasma_data_colours, plasma_data_pos, plasma_data_points, 200);
|
2011-10-19 18:34:31 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
if (cpu_check())
|
|
|
|
{
|
|
|
|
error_ui(vid_buf, 0, "Unsupported CPU. Try another version.");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-08-19 17:44:09 -05:00
|
|
|
http_ver_check = http_async_req_start(NULL, "http://" SERVER "/Update.api?Action=CheckVersion", NULL, 0, 0);
|
2011-04-08 09:28:57 -05:00
|
|
|
if (svf_login) {
|
2011-09-24 09:10:21 -05:00
|
|
|
http_auth_headers(http_ver_check, svf_user_id, NULL, svf_session_id); //Add authentication so beta checking can be done from user basis
|
2011-04-08 09:28:57 -05:00
|
|
|
http_session_check = http_async_req_start(NULL, "http://" SERVER "/Login.api?Action=CheckSession", NULL, 0, 0);
|
|
|
|
http_auth_headers(http_session_check, svf_user_id, NULL, svf_session_id);
|
|
|
|
}
|
2011-06-08 10:30:36 -05:00
|
|
|
#ifdef LUACONSOLE
|
|
|
|
luacon_eval("dofile(\"autorun.lua\")"); //Autorun lua script
|
|
|
|
#endif
|
2011-04-08 09:28:57 -05:00
|
|
|
while (!sdl_poll()) //the main loop
|
|
|
|
{
|
2011-04-12 06:19:21 -05:00
|
|
|
frameidx++;
|
|
|
|
frameidx %= 30;
|
2011-04-08 09:28:57 -05:00
|
|
|
if (!sys_pause||framerender) //only update air if not paused
|
|
|
|
{
|
|
|
|
update_air();
|
2011-06-01 14:18:19 -05:00
|
|
|
if(aheat_enable)
|
|
|
|
update_airh();
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
2011-07-18 17:58:08 -05:00
|
|
|
|
2011-11-01 06:42:44 -05:00
|
|
|
#ifdef OGLR
|
|
|
|
part_vbuf = vid_buf;
|
|
|
|
#else
|
2011-11-12 14:44:15 -06:00
|
|
|
if(ngrav_enable && display_mode & DISPLAY_WARP)
|
2011-07-18 17:58:08 -05:00
|
|
|
{
|
|
|
|
part_vbuf = part_vbuf_store;
|
|
|
|
memset(vid_buf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
|
|
|
} else {
|
|
|
|
part_vbuf = vid_buf;
|
|
|
|
}
|
2011-11-01 06:42:44 -05:00
|
|
|
#endif
|
2011-07-18 17:58:08 -05:00
|
|
|
|
2011-06-09 16:35:00 -05:00
|
|
|
if(gravwl_timeout)
|
|
|
|
{
|
|
|
|
if(gravwl_timeout==1)
|
|
|
|
gravity_mask();
|
|
|
|
gravwl_timeout--;
|
|
|
|
}
|
2011-10-20 09:37:21 -05:00
|
|
|
#ifdef OGLR
|
2011-11-12 14:44:15 -06:00
|
|
|
if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
|
2011-10-20 09:37:21 -05:00
|
|
|
{
|
2011-10-20 16:22:18 -05:00
|
|
|
clearScreen(0.01f);
|
2011-10-20 09:37:21 -05:00
|
|
|
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
|
|
|
}
|
|
|
|
else //clear screen every frame
|
|
|
|
{
|
|
|
|
clearScreen(1.0f);
|
|
|
|
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
2011-11-12 14:44:15 -06:00
|
|
|
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
|
2011-10-20 09:37:21 -05:00
|
|
|
{
|
|
|
|
draw_air(part_vbuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
2011-11-12 14:44:15 -06:00
|
|
|
if (display_mode & DISPLAY_AIR)//air only gets drawn in these modes
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-07-18 17:58:08 -05:00
|
|
|
draw_air(part_vbuf);
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
2011-11-12 14:44:15 -06:00
|
|
|
else if (display_mode & DISPLAY_PERS)//save background for persistent, then clear
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-07-18 17:58:08 -05:00
|
|
|
memcpy(part_vbuf, pers_bg, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
|
|
|
memset(part_vbuf+((XRES+BARSIZE)*YRES), 0, ((XRES+BARSIZE)*YRES*PIXELSIZE)-((XRES+BARSIZE)*YRES*PIXELSIZE));
|
2011-10-20 09:37:21 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else //clear screen every frame
|
|
|
|
{
|
2011-10-20 09:37:21 -05:00
|
|
|
memset(part_vbuf, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
2011-10-18 15:56:32 -05:00
|
|
|
}
|
2011-10-20 09:37:21 -05:00
|
|
|
#endif
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-04-22 11:06:09 -05:00
|
|
|
//Can't be too sure (Limit the cursor size)
|
2011-04-08 09:28:57 -05:00
|
|
|
if (bsx>1180)
|
|
|
|
bsx = 1180;
|
|
|
|
if (bsx<0)
|
|
|
|
bsx = 0;
|
|
|
|
if (bsy>1180)
|
|
|
|
bsy = 1180;
|
|
|
|
if (bsy<0)
|
|
|
|
bsy = 0;
|
2011-10-09 07:55:16 -05:00
|
|
|
|
|
|
|
//Pretty powders, colour cycle
|
|
|
|
//sandcolour_r = 0;
|
|
|
|
//sandcolour_g = 0;
|
|
|
|
sandcolour_b = sandcolour_r = sandcolour_g = (int)(20.0f*sin((float)sandcolour_frame*(M_PI/180.0f)));
|
|
|
|
sandcolour_frame++;
|
|
|
|
sandcolour_frame%=360;
|
2011-06-01 06:16:33 -05:00
|
|
|
|
2011-06-27 08:01:07 -05:00
|
|
|
if(ngrav_enable && drawgrav_enable)
|
2011-06-01 06:16:33 -05:00
|
|
|
draw_grav(vid_buf);
|
2011-07-18 17:58:08 -05:00
|
|
|
draw_walls(part_vbuf);
|
2011-10-16 18:16:43 -05:00
|
|
|
|
|
|
|
if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME))
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
#elif defined(MACOSX)
|
|
|
|
#else
|
|
|
|
struct timespec ts;
|
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
|
debug_perf_time = ts.tv_nsec;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-07-18 17:58:08 -05:00
|
|
|
update_particles(part_vbuf); //update everything
|
2011-10-16 18:16:43 -05:00
|
|
|
|
|
|
|
if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME))
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
#elif defined(MACOSX)
|
|
|
|
#else
|
|
|
|
struct timespec ts;
|
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
|
|
|
|
|
debug_perf_partitime[debug_perf_iend] = ts.tv_nsec - debug_perf_time;
|
|
|
|
|
|
|
|
debug_perf_time = ts.tv_nsec;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-10-10 14:42:55 -05:00
|
|
|
render_parts(part_vbuf); //draw particles
|
2011-10-10 17:41:19 -05:00
|
|
|
draw_other(part_vbuf);
|
2011-10-16 18:16:43 -05:00
|
|
|
|
|
|
|
if(debug_flags & (DEBUG_PERFORMANCE_CALC|DEBUG_PERFORMANCE_FRAME))
|
|
|
|
{
|
|
|
|
#ifdef WIN32
|
|
|
|
#elif defined(MACOSX)
|
|
|
|
#else
|
|
|
|
struct timespec ts;
|
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
|
|
|
|
|
debug_perf_frametime[debug_perf_iend] = ts.tv_nsec - debug_perf_time;
|
|
|
|
#endif
|
|
|
|
debug_perf_iend++;
|
|
|
|
debug_perf_iend %= DEBUG_PERF_FRAMECOUNT;
|
|
|
|
debug_perf_istart++;
|
|
|
|
debug_perf_istart %= DEBUG_PERF_FRAMECOUNT;
|
|
|
|
}
|
|
|
|
|
2011-06-09 16:35:00 -05:00
|
|
|
if(sl == WL_GRAV+100 || sr == WL_GRAV+100)
|
2011-07-18 17:58:08 -05:00
|
|
|
draw_grav_zones(part_vbuf);
|
2011-06-01 06:16:33 -05:00
|
|
|
|
2011-12-10 09:23:33 -06:00
|
|
|
gravity_update_async(); //Check for updated velocity maps from gravity thread
|
2011-04-25 14:41:45 -05:00
|
|
|
if (!sys_pause||framerender) //Only update if not paused
|
2011-12-24 13:07:24 -06:00
|
|
|
memset(gravmap, 0, (XRES/CELL)*(YRES/CELL)*sizeof(float)); //Clear the old gravmap
|
2011-04-08 09:28:57 -05:00
|
|
|
|
2011-06-16 18:58:08 -05:00
|
|
|
if (framerender) {
|
|
|
|
framerender = 0;
|
|
|
|
sys_pause = 1;
|
|
|
|
}
|
|
|
|
|
2011-11-12 14:44:15 -06:00
|
|
|
if (display_mode & DISPLAY_PERS)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (!fire_fc)//fire_fc has nothing to do with fire... it is a counter for diminishing persistent view every 3 frames
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
dim_copy_pers(pers_bg, vid_buf);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
memcpy(pers_bg, vid_buf, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
fire_fc = (fire_fc+1) % 3;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-10-20 09:37:21 -05:00
|
|
|
|
|
|
|
#ifndef OGLR
|
2011-11-12 14:44:15 -06:00
|
|
|
if (render_mode & FIREMODE)
|
2011-07-18 17:58:08 -05:00
|
|
|
render_fire(part_vbuf);
|
2011-10-20 09:37:21 -05:00
|
|
|
#endif
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-07-18 17:58:08 -05:00
|
|
|
render_signs(part_vbuf);
|
|
|
|
|
2011-11-01 06:42:44 -05:00
|
|
|
#ifndef OGLR
|
2011-11-12 14:44:15 -06:00
|
|
|
if(ngrav_enable && display_mode & DISPLAY_WARP)
|
2011-07-18 17:58:08 -05:00
|
|
|
render_gravlensing(part_vbuf, vid_buf);
|
2011-11-01 06:42:44 -05:00
|
|
|
#endif
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
memset(vid_buf+((XRES+BARSIZE)*YRES), 0, (PIXELSIZE*(XRES+BARSIZE))*MENUSIZE);//clear menu areas
|
|
|
|
clearrect(vid_buf, XRES-1, 0, BARSIZE+1, YRES);
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-06-14 09:13:27 -05:00
|
|
|
draw_svf_ui(vid_buf, sdl_mod & (KMOD_LCTRL|KMOD_RCTRL));
|
2011-08-11 14:12:52 -05:00
|
|
|
|
|
|
|
if(debug_flags)
|
|
|
|
{
|
2011-08-19 10:13:36 -05:00
|
|
|
draw_debug_info(vid_buf, lm, lx, ly, x, y, line_x, line_y);
|
2011-08-11 14:12:52 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
|
2011-08-19 17:44:09 -05:00
|
|
|
if (http_ver_check)
|
|
|
|
{
|
|
|
|
if (!do_check && http_async_req_status(http_ver_check))
|
|
|
|
{
|
|
|
|
ver_data = http_async_req_stop(http_ver_check, &http_ret, NULL);
|
|
|
|
if (http_ret==200 && ver_data)
|
|
|
|
{
|
2011-09-24 10:57:01 -05:00
|
|
|
if (sscanf(ver_data, "%d.%d.%d.%d", &major, &minor, &is_beta, &buildnum)==4)
|
|
|
|
if (buildnum>BUILD_NUM)
|
2011-08-19 17:44:09 -05:00
|
|
|
old_version = 1;
|
2011-09-24 10:57:01 -05:00
|
|
|
if (is_beta)
|
|
|
|
{
|
|
|
|
old_ver_len = textwidth((char*)old_ver_msg_beta);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
old_ver_len = textwidth((char*)old_ver_msg);
|
|
|
|
}
|
2011-08-19 17:44:09 -05:00
|
|
|
free(ver_data);
|
|
|
|
}
|
|
|
|
http_ver_check = NULL;
|
|
|
|
}
|
|
|
|
do_check = (do_check+1) & 15;
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (http_session_check)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (!do_s_check && http_async_req_status(http_session_check))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
check_data = http_async_req_stop(http_session_check, &http_s_ret, NULL);
|
|
|
|
if (http_ret==200 && check_data)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (!strncmp(check_data, "EXPIRED", 7))
|
|
|
|
{
|
|
|
|
//Session expired
|
2011-09-24 10:57:01 -05:00
|
|
|
printf("EXPIRED");
|
2011-04-08 09:28:57 -05:00
|
|
|
strcpy(svf_user, "");
|
|
|
|
strcpy(svf_pass, "");
|
|
|
|
strcpy(svf_user_id, "");
|
|
|
|
strcpy(svf_session_id, "");
|
|
|
|
svf_login = 0;
|
|
|
|
svf_own = 0;
|
|
|
|
svf_admin = 0;
|
|
|
|
svf_mod = 0;
|
2011-05-16 06:46:08 -05:00
|
|
|
svf_messages = 0;
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
else if (!strncmp(check_data, "BANNED", 6))
|
|
|
|
{
|
|
|
|
//User banned
|
2011-09-24 10:57:01 -05:00
|
|
|
printf("BANNED");
|
2011-04-08 09:28:57 -05:00
|
|
|
strcpy(svf_user, "");
|
|
|
|
strcpy(svf_pass, "");
|
|
|
|
strcpy(svf_user_id, "");
|
|
|
|
strcpy(svf_session_id, "");
|
|
|
|
svf_login = 0;
|
|
|
|
svf_own = 0;
|
|
|
|
svf_admin = 0;
|
|
|
|
svf_mod = 0;
|
2011-05-16 06:46:08 -05:00
|
|
|
svf_messages = 0;
|
2011-04-08 09:28:57 -05:00
|
|
|
error_ui(vid_buf, 0, "Unable to log in\nYour account has been suspended, consider reading the rules.");
|
|
|
|
}
|
|
|
|
else if (!strncmp(check_data, "OK", 2))
|
|
|
|
{
|
|
|
|
//Session valid
|
|
|
|
if (strlen(check_data)>2) {
|
|
|
|
//User is elevated
|
2011-05-19 15:41:13 -05:00
|
|
|
if (!strncmp(check_data+3, "ADMIN", 5))
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-05-19 15:41:13 -05:00
|
|
|
//Check for messages
|
|
|
|
svf_messages = atoi(check_data+9);
|
2011-04-08 09:28:57 -05:00
|
|
|
svf_admin = 1;
|
|
|
|
svf_mod = 0;
|
|
|
|
}
|
|
|
|
else if (!strncmp(check_data+3, "MOD", 3))
|
|
|
|
{
|
2011-05-19 15:41:13 -05:00
|
|
|
//Check for messages
|
|
|
|
svf_messages = atoi(check_data+7);
|
2011-04-08 09:28:57 -05:00
|
|
|
svf_admin = 0;
|
|
|
|
svf_mod = 1;
|
2011-05-19 15:41:13 -05:00
|
|
|
} else {
|
|
|
|
//Check for messages
|
|
|
|
svf_messages = atoi(check_data+3);
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-03-15 10:53:21 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
//No idea, but log the user out anyway
|
|
|
|
strcpy(svf_user, "");
|
|
|
|
strcpy(svf_pass, "");
|
|
|
|
strcpy(svf_user_id, "");
|
|
|
|
strcpy(svf_session_id, "");
|
|
|
|
svf_login = 0;
|
|
|
|
svf_own = 0;
|
|
|
|
svf_admin = 0;
|
|
|
|
svf_mod = 0;
|
2011-05-16 06:46:08 -05:00
|
|
|
svf_messages = 0;
|
2011-03-15 10:53:21 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
save_presets(0);
|
|
|
|
free(check_data);
|
2011-02-20 14:55:47 -06:00
|
|
|
} else {
|
2011-04-08 09:28:57 -05:00
|
|
|
//Unable to check session, YOU WILL BE TERMINATED
|
|
|
|
strcpy(svf_user, "");
|
|
|
|
strcpy(svf_pass, "");
|
|
|
|
strcpy(svf_user_id, "");
|
|
|
|
strcpy(svf_session_id, "");
|
|
|
|
svf_login = 0;
|
|
|
|
svf_own = 0;
|
|
|
|
svf_admin = 0;
|
|
|
|
svf_mod = 0;
|
2011-05-16 06:46:08 -05:00
|
|
|
svf_messages = 0;
|
2011-02-20 14:55:47 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
http_session_check = NULL;
|
|
|
|
} else {
|
|
|
|
clearrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14);
|
|
|
|
drawrect(vid_buf, XRES-125+BARSIZE/*385*/, YRES+(MENUSIZE-16), 91, 14, 255, 255, 255, 255);
|
|
|
|
drawtext(vid_buf, XRES-122+BARSIZE/*388*/, YRES+(MENUSIZE-13), "\x84", 255, 255, 255, 255);
|
|
|
|
if (username_flash>30) {
|
|
|
|
username_flash_t = -1;
|
|
|
|
username_flash = 30;
|
|
|
|
} else if (username_flash<0) {
|
|
|
|
username_flash_t = 1;
|
|
|
|
username_flash = 0;
|
2011-02-20 14:55:47 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
username_flash += username_flash_t;
|
|
|
|
if (svf_login)
|
|
|
|
drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), svf_user, 255, 255, 255, 175-(username_flash*5));
|
2011-01-28 17:54:50 -06:00
|
|
|
else
|
2011-04-08 09:28:57 -05:00
|
|
|
drawtext(vid_buf, XRES-104+BARSIZE/*406*/, YRES+(MENUSIZE-12), "[checking]", 255, 255, 255, 255);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
do_s_check = (do_s_check+1) & 15;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-08-05 08:54:24 -05:00
|
|
|
#ifdef LUACONSOLE
|
|
|
|
if(sdl_key){
|
2011-08-20 12:18:09 -05:00
|
|
|
if(!luacon_keyevent(sdl_key, sdl_mod, LUACON_KDOWN))
|
2011-08-05 08:54:24 -05:00
|
|
|
sdl_key = 0;
|
|
|
|
}
|
2011-08-20 12:18:09 -05:00
|
|
|
if(sdl_rkey){
|
|
|
|
if(!luacon_keyevent(sdl_rkey, sdl_mod, LUACON_KUP))
|
|
|
|
sdl_rkey = 0;
|
|
|
|
}
|
2011-08-05 08:54:24 -05:00
|
|
|
#endif
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sys_shortcuts==1)//all shortcuts can be disabled by python scripts
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='q' || sdl_key==SDLK_ESCAPE)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (confirm_ui(vid_buf, "You are about to quit", "Are you sure you want to quit?", "Quit"))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='i' && (sdl_mod & KMOD_CTRL))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if(confirm_ui(vid_buf, "Install Powder Toy", "You are about to install The Powder Toy", "Install"))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if(register_extension())
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
info_ui(vid_buf, "Install success", "Powder Toy has been installed!");
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
else
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
error_ui(vid_buf, 0, "Install failed - You may not have permission or you may be on a platform that does not support installation");
|
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='f')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
framerender = 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if ((sdl_key=='l' || sdl_key=='k') && stamps[0].name[0])
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (load_mode)
|
|
|
|
{
|
|
|
|
free(load_img);
|
|
|
|
free(load_data);
|
|
|
|
load_mode = 0;
|
|
|
|
load_data = NULL;
|
|
|
|
load_img = NULL;
|
|
|
|
}
|
|
|
|
if (it > 50)
|
|
|
|
it = 50;
|
|
|
|
if (sdl_key=='k' && stamps[1].name[0])
|
|
|
|
{
|
|
|
|
j = stamp_ui(vid_buf);
|
|
|
|
if (j>=0)
|
|
|
|
load_data = stamp_load(j, &load_size);
|
|
|
|
else
|
|
|
|
load_data = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
load_data = stamp_load(0, &load_size);
|
|
|
|
if (load_data)
|
|
|
|
{
|
|
|
|
load_img = prerender_save(load_data, load_size, &load_w, &load_h);
|
|
|
|
if (load_img)
|
|
|
|
load_mode = 1;
|
|
|
|
else
|
|
|
|
free(load_data);
|
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-10-23 03:22:31 -05:00
|
|
|
if (sdl_key=='s' && ((sdl_mod & (KMOD_CTRL)) || !player2.spwn))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (it > 50)
|
|
|
|
it = 50;
|
|
|
|
save_mode = 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-11-12 14:44:15 -06:00
|
|
|
//TODO: Superseded by new display mode switching, need some keyboard shortcuts
|
2011-11-14 17:21:39 -06:00
|
|
|
if (sdl_key=='1')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_VEL);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='2')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_PRESS);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='3')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_PERS);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='4')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_FIRE);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='5')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_BLOB);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='6')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_HEAT);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='7')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_FANCY);
|
|
|
|
}
|
|
|
|
if (sdl_key=='8')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_NOTHING);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='9')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_GRAD);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='0')
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_CRACK);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
set_cmode(CM_LIFE);
|
2011-11-14 17:21:39 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key==SDLK_TAB)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ;
|
|
|
|
}
|
|
|
|
if (sdl_key==SDLK_LEFTBRACKET) {
|
2011-08-27 07:14:20 -05:00
|
|
|
if (sdl_zoom_trig)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
ZSIZE -= 1;
|
|
|
|
if (ZSIZE>60)
|
|
|
|
ZSIZE = 60;
|
|
|
|
if (ZSIZE<2)
|
|
|
|
ZSIZE = 2;
|
|
|
|
ZFACTOR = 256/ZSIZE;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
bsx -= 1;
|
|
|
|
bsy -= 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
bsx -= 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
bsy -= 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
bsx -= ceil((bsx/5)+0.5f);
|
|
|
|
bsy -= ceil((bsy/5)+0.5f);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (bsx>1180)
|
|
|
|
bsx = 1180;
|
|
|
|
if (bsy>1180)
|
|
|
|
bsy = 1180;
|
|
|
|
if (bsx<0)
|
|
|
|
bsx = 0;
|
|
|
|
if (bsy<0)
|
|
|
|
bsy = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sdl_key==SDLK_RIGHTBRACKET) {
|
2011-08-27 07:14:20 -05:00
|
|
|
if (sdl_zoom_trig)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
ZSIZE += 1;
|
|
|
|
if (ZSIZE>60)
|
|
|
|
ZSIZE = 60;
|
|
|
|
if (ZSIZE<2)
|
|
|
|
ZSIZE = 2;
|
|
|
|
ZFACTOR = 256/ZSIZE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sdl_mod & (KMOD_LALT|KMOD_RALT) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
bsx += 1;
|
|
|
|
bsy += 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
bsx += 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
bsy += 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
bsx += ceil((bsx/5)+0.5f);
|
|
|
|
bsy += ceil((bsy/5)+0.5f);
|
2010-12-08 11:14:02 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (bsx>1180)
|
|
|
|
bsx = 1180;
|
|
|
|
if (bsy>1180)
|
|
|
|
bsy = 1180;
|
|
|
|
if (bsx<0)
|
|
|
|
bsx = 0;
|
|
|
|
if (bsy<0)
|
|
|
|
bsy = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-10-23 03:22:31 -05:00
|
|
|
if (sdl_key=='d' && ((sdl_mod & (KMOD_CTRL)) || !player2.spwn))
|
2011-04-08 09:28:57 -05:00
|
|
|
DEBUG_MODE = !DEBUG_MODE;
|
|
|
|
if (sdl_key=='i')
|
|
|
|
{
|
|
|
|
int nx, ny;
|
|
|
|
for (nx = 0; nx<XRES/CELL; nx++)
|
|
|
|
for (ny = 0; ny<YRES/CELL; ny++)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
pv[ny][nx] = -pv[ny][nx];
|
|
|
|
vx[ny][nx] = -vx[ny][nx];
|
|
|
|
vy[ny][nx] = -vy[ny][nx];
|
|
|
|
}
|
|
|
|
}
|
2011-05-24 09:01:18 -05:00
|
|
|
if (sdl_key==SDLK_INSERT || sdl_key == SDLK_SEMICOLON)// || sdl_key==SDLK_BACKQUOTE)
|
2011-04-08 09:28:57 -05:00
|
|
|
REPLACE_MODE = !REPLACE_MODE;
|
|
|
|
if (sdl_key==SDLK_BACKQUOTE)
|
|
|
|
{
|
|
|
|
console_mode = !console_mode;
|
|
|
|
//hud_enable = !console_mode;
|
|
|
|
}
|
2011-04-22 22:11:05 -05:00
|
|
|
if (sdl_key=='b')
|
2011-04-23 22:17:35 -05:00
|
|
|
{
|
2011-05-21 07:27:19 -05:00
|
|
|
if (sdl_mod & KMOD_CTRL)
|
|
|
|
{
|
|
|
|
decorations_enable = !decorations_enable;
|
|
|
|
itc = 51;
|
|
|
|
if (decorations_enable) strcpy(itc_msg, "Decorations layer: On");
|
|
|
|
else strcpy(itc_msg, "Decorations layer: Off");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-19 11:31:14 -05:00
|
|
|
rgbSave = decorations_ui(vid_buf,&bsx,&bsy,rgbSave);//decoration_mode = !decoration_mode;
|
2011-05-21 07:27:19 -05:00
|
|
|
decorations_enable = 1;
|
|
|
|
sys_pause=1;
|
|
|
|
}
|
2011-04-23 22:17:35 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='g')
|
|
|
|
{
|
2011-06-27 08:01:07 -05:00
|
|
|
if(sdl_mod & (KMOD_CTRL))
|
|
|
|
{
|
|
|
|
drawgrav_enable =! drawgrav_enable;
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-06-27 08:01:07 -05:00
|
|
|
{
|
|
|
|
if (sdl_mod & (KMOD_SHIFT))
|
|
|
|
GRID_MODE = (GRID_MODE+9)%10;
|
|
|
|
else
|
|
|
|
GRID_MODE = (GRID_MODE+1)%10;
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
2011-04-17 14:34:54 -05:00
|
|
|
if (sdl_key=='m')
|
|
|
|
{
|
|
|
|
if(sl!=sr)
|
|
|
|
{
|
|
|
|
sl ^= sr;
|
|
|
|
sr ^= sl;
|
|
|
|
sl ^= sr;
|
|
|
|
}
|
|
|
|
dae = 51;
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='=')
|
|
|
|
{
|
|
|
|
int nx, ny;
|
|
|
|
if (sdl_mod & (KMOD_CTRL))
|
|
|
|
{
|
|
|
|
for (i=0; i<NPART; i++)
|
|
|
|
if (parts[i].type==PT_SPRK)
|
|
|
|
{
|
|
|
|
parts[i].type = parts[i].ctype;
|
|
|
|
parts[i].life = 0;
|
2010-12-30 13:59:39 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (nx = 0; nx<XRES/CELL; nx++)
|
|
|
|
for (ny = 0; ny<YRES/CELL; ny++)
|
|
|
|
{
|
|
|
|
pv[ny][nx] = 0;
|
|
|
|
vx[ny][nx] = 0;
|
|
|
|
vy[ny][nx] = 0;
|
2010-12-30 13:59:39 -06:00
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
}
|
2011-02-03 12:45:56 -06:00
|
|
|
|
2011-10-23 03:22:31 -05:00
|
|
|
if (sdl_key=='w' && (!player2.spwn || (sdl_mod & (KMOD_SHIFT)))) //Gravity, by Moach
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
++gravityMode; // cycle gravity mode
|
|
|
|
itc = 51;
|
2011-02-03 12:45:56 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
switch (gravityMode)
|
2011-01-31 10:54:13 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
default:
|
|
|
|
gravityMode = 0;
|
|
|
|
case 0:
|
|
|
|
strcpy(itc_msg, "Gravity: Vertical");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
strcpy(itc_msg, "Gravity: Off");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
strcpy(itc_msg, "Gravity: Radial");
|
|
|
|
break;
|
2011-02-03 12:45:56 -06:00
|
|
|
|
2011-01-31 10:54:13 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
if (sdl_key=='y')
|
|
|
|
{
|
|
|
|
++airMode;
|
|
|
|
itc = 52;
|
2011-02-03 12:45:56 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
switch (airMode)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
default:
|
|
|
|
airMode = 0;
|
|
|
|
case 0:
|
|
|
|
strcpy(itc_msg, "Air: On");
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
strcpy(itc_msg, "Air: Pressure Off");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
strcpy(itc_msg, "Air: Velocity Off");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
strcpy(itc_msg, "Air: Off");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
strcpy(itc_msg, "Air: No Update");
|
|
|
|
break;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sdl_key=='t')
|
|
|
|
VINE_MODE = !VINE_MODE;
|
|
|
|
if (sdl_key==SDLK_SPACE)
|
|
|
|
sys_pause = !sys_pause;
|
2011-06-01 14:18:19 -05:00
|
|
|
if (sdl_key=='u')
|
|
|
|
aheat_enable = !aheat_enable;
|
2011-10-24 13:05:03 -05:00
|
|
|
if (sdl_key=='h' && !(sdl_mod & KMOD_LCTRL))
|
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
hud_enable = !hud_enable;
|
2011-10-24 13:05:03 -05:00
|
|
|
}
|
|
|
|
if (sdl_key==SDLK_F1 || (sdl_key=='h' && (sdl_mod & KMOD_LCTRL)))
|
|
|
|
{
|
|
|
|
if(!it)
|
|
|
|
{
|
|
|
|
it = 8047;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
it = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-10-09 07:55:16 -05:00
|
|
|
if (sdl_key=='n')
|
|
|
|
pretty_powder = !pretty_powder;
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='p')
|
|
|
|
dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE);
|
|
|
|
if (sdl_key=='v'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
|
|
|
|
{
|
|
|
|
if (clipboard_ready==1)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
load_data = malloc(clipboard_length);
|
|
|
|
memcpy(load_data, clipboard_data, clipboard_length);
|
|
|
|
load_size = clipboard_length;
|
|
|
|
if (load_data)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
load_img = prerender_save(load_data, load_size, &load_w, &load_h);
|
|
|
|
if (load_img)
|
|
|
|
load_mode = 1;
|
2011-02-24 11:11:05 -06:00
|
|
|
else
|
2011-04-08 09:28:57 -05:00
|
|
|
free(load_data);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
if (load_mode==1)
|
|
|
|
{
|
|
|
|
matrix2d transform = m2d_identity;
|
|
|
|
vector2d translate = v2d_zero;
|
|
|
|
void *ndata;
|
|
|
|
int doTransform = 0;
|
|
|
|
if (sdl_key=='r'&&(sdl_mod & (KMOD_CTRL))&&(sdl_mod & (KMOD_SHIFT)))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
transform = m2d_new(-1,0,0,1); //horizontal invert
|
|
|
|
doTransform = 1;
|
|
|
|
}
|
|
|
|
else if (sdl_key=='r'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
|
|
|
|
{
|
|
|
|
transform = m2d_new(0,1,-1,0); //rotate anticlockwise 90 degrees
|
|
|
|
doTransform = 1;
|
|
|
|
}
|
|
|
|
else if (sdl_mod & (KMOD_CTRL))
|
|
|
|
{
|
|
|
|
doTransform = 1;
|
|
|
|
if (sdl_key==SDLK_LEFT) translate = v2d_new(-1,0);
|
|
|
|
else if (sdl_key==SDLK_RIGHT) translate = v2d_new(1,0);
|
|
|
|
else if (sdl_key==SDLK_UP) translate = v2d_new(0,-1);
|
|
|
|
else if (sdl_key==SDLK_DOWN) translate = v2d_new(0,1);
|
|
|
|
else doTransform = 0;
|
|
|
|
}
|
|
|
|
if (doTransform)
|
|
|
|
{
|
|
|
|
ndata = transform_save(load_data, &load_size, transform, translate);
|
|
|
|
if (ndata!=load_data) free(load_data);
|
|
|
|
free(load_img);
|
|
|
|
load_data = ndata;
|
|
|
|
load_img = prerender_save(load_data, load_size, &load_w, &load_h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sdl_key=='r'&&!(sdl_mod & (KMOD_CTRL|KMOD_SHIFT)))
|
|
|
|
GENERATION = 0;
|
|
|
|
if (sdl_key=='x'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
|
|
|
|
{
|
|
|
|
save_mode = 1;
|
|
|
|
copy_mode = 2;
|
|
|
|
}
|
|
|
|
if (sdl_key=='c'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))
|
|
|
|
{
|
|
|
|
save_mode = 1;
|
|
|
|
copy_mode = 1;
|
|
|
|
}
|
2011-11-12 14:44:15 -06:00
|
|
|
//TODO: Superseded by new display mode switching, need some keyboard shortcuts
|
|
|
|
/*else if (sdl_key=='c')
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
set_cmode((cmode+1) % CM_COUNT);
|
|
|
|
if (it > 50)
|
|
|
|
it = 50;
|
2011-11-12 14:44:15 -06:00
|
|
|
}*/
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_key=='z'&&(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))) // Undo
|
|
|
|
{
|
|
|
|
int cbx, cby, cbi;
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
for (cbi=0; cbi<NPART; cbi++)
|
|
|
|
parts[cbi] = cb_parts[cbi];
|
2011-08-29 18:23:25 -05:00
|
|
|
parts_lastActiveIndex = NPART-1;
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
for (cby = 0; cby<YRES; cby++)
|
|
|
|
for (cbx = 0; cbx<XRES; cbx++)
|
|
|
|
pmap[cby][cbx] = cb_pmap[cby][cbx];
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
for (cby = 0; cby<(YRES/CELL); cby++)
|
|
|
|
for (cbx = 0; cbx<(XRES/CELL); cbx++)
|
|
|
|
{
|
|
|
|
vx[cby][cbx] = cb_vx[cby][cbx];
|
|
|
|
vy[cby][cbx] = cb_vy[cby][cbx];
|
|
|
|
pv[cby][cbx] = cb_pv[cby][cbx];
|
2011-06-18 06:19:47 -05:00
|
|
|
hv[cby][cbx] = cb_hv[cby][cbx];
|
2011-04-08 09:28:57 -05:00
|
|
|
bmap[cby][cbx] = cb_bmap[cby][cbx];
|
|
|
|
emap[cby][cbx] = cb_emap[cby][cbx];
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
#ifdef INTERNAL
|
|
|
|
int counterthing;
|
|
|
|
if (sdl_key=='v'&&!(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL)))//frame capture
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_mod & (KMOD_SHIFT)) {
|
|
|
|
if (vs>=1)
|
|
|
|
vs = 0;
|
|
|
|
else
|
|
|
|
vs = 3;//every other frame
|
|
|
|
}
|
|
|
|
else
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (vs>=1)
|
|
|
|
vs = 0;
|
|
|
|
else
|
|
|
|
vs = 1;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
counterthing = 0;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (vs)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (counterthing+1>=vs)
|
|
|
|
{
|
|
|
|
dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE);
|
|
|
|
counterthing = 0;
|
|
|
|
}
|
|
|
|
counterthing = (counterthing+1)%3;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
#endif
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_wheel)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-08-27 07:14:20 -05:00
|
|
|
if (sdl_zoom_trig)//zoom window change
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
ZSIZE += sdl_wheel;
|
|
|
|
if (ZSIZE>60)
|
|
|
|
ZSIZE = 60;
|
|
|
|
if (ZSIZE<2)
|
|
|
|
ZSIZE = 2;
|
|
|
|
ZFACTOR = 256/ZSIZE;
|
|
|
|
sdl_wheel = 0;
|
|
|
|
}
|
|
|
|
else //change brush size
|
|
|
|
{
|
|
|
|
if (!(sdl_mod & (KMOD_SHIFT|KMOD_CTRL)))
|
|
|
|
{
|
|
|
|
bsx += sdl_wheel;
|
|
|
|
bsy += sdl_wheel;
|
|
|
|
}
|
|
|
|
else if (sdl_mod & (KMOD_SHIFT) && !(sdl_mod & (KMOD_CTRL)))
|
|
|
|
{
|
|
|
|
bsx += sdl_wheel;
|
|
|
|
}
|
|
|
|
else if (sdl_mod & (KMOD_CTRL) && !(sdl_mod & (KMOD_SHIFT)))
|
|
|
|
{
|
|
|
|
bsy += sdl_wheel;
|
|
|
|
}
|
|
|
|
if (bsx>1180)
|
|
|
|
bsx = 1180;
|
|
|
|
if (bsx<0)
|
|
|
|
bsx = 0;
|
|
|
|
if (bsy>1180)
|
|
|
|
bsy = 1180;
|
|
|
|
if (bsy<0)
|
|
|
|
bsy = 0;
|
|
|
|
sdl_wheel = 0;
|
|
|
|
/*if(su >= PT_NUM) {
|
|
|
|
if(sl < PT_NUM)
|
|
|
|
su = sl;
|
|
|
|
if(sr < PT_NUM)
|
|
|
|
su = sr;
|
|
|
|
}*/
|
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
|
2011-09-18 14:47:10 -05:00
|
|
|
bq = bc; // bq is previous mouse state
|
2011-08-20 12:18:09 -05:00
|
|
|
bc = b = SDL_GetMouseState(&x, &y); // b is current mouse state
|
2011-04-08 09:28:57 -05:00
|
|
|
|
2011-05-31 12:38:13 -05:00
|
|
|
#ifdef LUACONSOLE
|
2011-08-20 12:18:09 -05:00
|
|
|
if(bc && bq){
|
|
|
|
if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bc, LUACON_MPRESS)){
|
|
|
|
b = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(bc && !bq){
|
|
|
|
if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bc, LUACON_MDOWN)){
|
|
|
|
b = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(!bc && bq){
|
|
|
|
if(!luacon_mouseevent(x/sdl_scale, y/sdl_scale, bq, LUACON_MUP)){
|
2011-08-05 08:54:24 -05:00
|
|
|
b = 0;
|
|
|
|
}
|
|
|
|
}
|
2011-09-23 22:25:50 -05:00
|
|
|
luacon_step(x/sdl_scale, y/sdl_scale,sl,sr);
|
2011-05-31 12:38:13 -05:00
|
|
|
#endif
|
|
|
|
|
2011-10-21 13:41:12 -05:00
|
|
|
quickoptions_menu(vid_buf, b, bq, x, y);
|
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
for (i=0; i<SC_TOTAL; i++)//draw all the menu sections
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
draw_menu(vid_buf, i, active_menu);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
for (i=0; i<SC_TOTAL; i++)//check mouse position to see if it is on a menu section
|
|
|
|
{
|
|
|
|
if (!b&&x>=sdl_scale*(XRES-2) && x<sdl_scale*(XRES+BARSIZE-1) &&y>= sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)) && y<sdl_scale*((i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16)+15))
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
active_menu = i;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
2012-03-14 18:26:08 -05:00
|
|
|
menu_ui_v3(vid_buf, active_menu, &sl, &sr, &su, &dae, b, bq, x, y); //draw the elements in the current menu
|
2011-04-08 09:28:57 -05:00
|
|
|
if (zoom_en && x>=sdl_scale*zoom_wx && y>=sdl_scale*zoom_wy //change mouse position while it is in a zoom window
|
|
|
|
&& x<sdl_scale*(zoom_wx+ZFACTOR*ZSIZE)
|
|
|
|
&& y<sdl_scale*(zoom_wy+ZFACTOR*ZSIZE))
|
|
|
|
{
|
|
|
|
x = (((x/sdl_scale-zoom_wx)/ZFACTOR)+zoom_x)*sdl_scale;
|
|
|
|
y = (((y/sdl_scale-zoom_wy)/ZFACTOR)+zoom_y)*sdl_scale;
|
|
|
|
}
|
|
|
|
if (y>0 && y<sdl_scale*YRES && x>0 && x<sdl_scale*XRES)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
int cr; //cr is particle under mouse, for drawing HUD information
|
2011-07-25 14:04:41 -05:00
|
|
|
char nametext[50];
|
2011-04-08 09:28:57 -05:00
|
|
|
if (photons[y/sdl_scale][x/sdl_scale]) {
|
|
|
|
cr = photons[y/sdl_scale][x/sdl_scale];
|
|
|
|
} else {
|
|
|
|
cr = pmap[y/sdl_scale][x/sdl_scale];
|
|
|
|
}
|
2011-08-24 10:35:52 -05:00
|
|
|
if (cr)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-07-25 14:04:41 -05:00
|
|
|
if ((cr&0xFF)==PT_LIFE && parts[cr>>8].ctype>=0 && parts[cr>>8].ctype<NGOLALT)
|
|
|
|
{
|
|
|
|
sprintf(nametext, "%s (%s)", ptypes[cr&0xFF].name, gmenu[parts[cr>>8].ctype].name);
|
|
|
|
}
|
2011-08-20 12:23:27 -05:00
|
|
|
else if ((cr&0xFF)==PT_LAVA && parts[cr>>8].ctype > 0 && parts[cr>>8].ctype < PT_NUM )
|
2011-08-20 11:44:25 -05:00
|
|
|
{
|
|
|
|
char lowername[6];
|
|
|
|
int ix;
|
2011-09-02 17:24:29 -05:00
|
|
|
strcpy(lowername, ptypes[parts[cr>>8].ctype].name);
|
2011-08-20 11:44:25 -05:00
|
|
|
for (ix = 0; lowername[ix]; ix++)
|
|
|
|
lowername[ix] = tolower(lowername[ix]);
|
|
|
|
|
|
|
|
sprintf(nametext, "Molten %s", lowername);
|
|
|
|
}
|
2011-11-12 08:04:29 -06:00
|
|
|
else if ((cr&0xFF)==PT_PIPE && (parts[cr>>8].tmp&0xFF) > 0 && (parts[cr>>8].tmp&0xFF) < PT_NUM )
|
|
|
|
{
|
|
|
|
char lowername[6];
|
|
|
|
int ix;
|
|
|
|
strcpy(lowername, ptypes[parts[cr>>8].tmp&0xFF].name);
|
|
|
|
for (ix = 0; lowername[ix]; ix++)
|
|
|
|
lowername[ix] = tolower(lowername[ix]);
|
|
|
|
|
|
|
|
sprintf(nametext, "Pipe with %s", lowername);
|
|
|
|
}
|
2011-07-25 14:04:41 -05:00
|
|
|
else if (DEBUG_MODE)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
int tctype = parts[cr>>8].ctype;
|
|
|
|
if ((cr&0xFF)==PT_PIPE)
|
|
|
|
{
|
2011-08-29 18:23:25 -05:00
|
|
|
tctype = parts[cr>>8].tmp&0xFF;
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
2011-07-06 04:08:13 -05:00
|
|
|
if (tctype>=PT_NUM || tctype<0 || (cr&0xFF)==PT_PHOT)
|
|
|
|
tctype = 0;
|
2011-07-25 14:04:41 -05:00
|
|
|
sprintf(nametext, "%s (%s)", ptypes[cr&0xFF].name, ptypes[tctype].name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(nametext, ptypes[cr&0xFF].name);
|
|
|
|
}
|
|
|
|
if (DEBUG_MODE)
|
|
|
|
{
|
2011-10-11 04:34:33 -05:00
|
|
|
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp);
|
2011-04-08 09:28:57 -05:00
|
|
|
sprintf(coordtext, "#%d, X:%d Y:%d", cr>>8, x/sdl_scale, y/sdl_scale);
|
2011-07-25 14:04:41 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
#ifdef BETA
|
2011-10-11 04:34:33 -05:00
|
|
|
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C, Life: %d, Tmp:%d", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f, parts[cr>>8].life, parts[cr>>8].tmp);
|
2011-04-08 09:28:57 -05:00
|
|
|
#else
|
2011-07-25 14:04:41 -05:00
|
|
|
sprintf(heattext, "%s, Pressure: %3.2f, Temp: %4.2f C", nametext, pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL], parts[cr>>8].temp-273.15f);
|
2011-04-08 09:28:57 -05:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if ((cr&0xFF)==PT_PHOT) wavelength_gfx = parts[cr>>8].ctype;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(heattext, "Empty, Pressure: %3.2f", pv[(y/sdl_scale)/CELL][(x/sdl_scale)/CELL]);
|
|
|
|
if (DEBUG_MODE)
|
|
|
|
{
|
2012-03-14 20:06:32 -05:00
|
|
|
if (ngrav_enable)
|
|
|
|
sprintf(coordtext, "X:%d Y:%d. GX: %.2f GY: %.2f", x/sdl_scale, y/sdl_scale, gravx[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)], gravy[(((y/sdl_scale)/CELL)*(XRES/CELL))+((x/sdl_scale)/CELL)]);
|
|
|
|
else
|
|
|
|
sprintf(coordtext, "X:%d Y:%d", x/sdl_scale, y/sdl_scale);
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
|
2011-07-24 08:31:24 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
mx = x;
|
|
|
|
my = y;
|
2011-05-19 02:08:59 -05:00
|
|
|
if (b && !bq && x>=(XRES-19-new_message_len)*sdl_scale &&
|
|
|
|
x<=(XRES-14)*sdl_scale && y>=(YRES-37)*sdl_scale && y<=(YRES-24)*sdl_scale && svf_messages)
|
|
|
|
{
|
|
|
|
open_link("http://" SERVER "/Conversations.html");
|
|
|
|
}
|
2011-08-19 17:44:09 -05:00
|
|
|
if (update_flag)
|
|
|
|
{
|
|
|
|
info_box(vid_buf, "Finalizing update...");
|
2011-09-24 11:13:28 -05:00
|
|
|
if (last_build>BUILD_NUM)
|
2011-08-19 17:44:09 -05:00
|
|
|
{
|
|
|
|
update_cleanup();
|
|
|
|
error_ui(vid_buf, 0, "Update failed - try downloading a new version.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (update_finish())
|
|
|
|
error_ui(vid_buf, 0, "Update failed - try downloading a new version.");
|
|
|
|
else
|
|
|
|
info_ui(vid_buf, "Update success", "You have successfully updated the Powder Toy!");
|
|
|
|
}
|
|
|
|
update_flag = 0;
|
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-08-19 17:44:09 -05:00
|
|
|
if (b && !bq && x>=(XRES-19-old_ver_len)*sdl_scale &&
|
|
|
|
x<=(XRES-14)*sdl_scale && y>=(YRES-22)*sdl_scale && y<=(YRES-9)*sdl_scale && old_version)
|
|
|
|
{
|
2011-09-24 10:57:01 -05:00
|
|
|
tmp = malloc(128);
|
2011-08-19 17:44:09 -05:00
|
|
|
#ifdef BETA
|
|
|
|
if (is_beta)
|
|
|
|
{
|
2011-09-24 10:57:01 -05:00
|
|
|
sprintf(tmp, "Your version: %d.%d Beta (%d)\nNew version: %d.%d Beta (%d)", SAVE_VERSION, MINOR_VERSION, BUILD_NUM, major, minor, buildnum);
|
2011-08-19 17:44:09 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-24 10:57:01 -05:00
|
|
|
sprintf(tmp, "Your version: %d.%d Beta (%d)\nNew version: %d.%d (%d)", SAVE_VERSION, MINOR_VERSION, BUILD_NUM, major, minor, buildnum);
|
2011-08-19 17:44:09 -05:00
|
|
|
}
|
|
|
|
#else
|
2011-09-24 10:57:01 -05:00
|
|
|
if (is_beta)
|
|
|
|
{
|
|
|
|
sprintf(tmp, "Your version: %d.%d (%d)\nNew version: %d.%d Beta (%d)", SAVE_VERSION, MINOR_VERSION, BUILD_NUM, major, minor, buildnum);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sprintf(tmp, "Your version: %d.%d (%d)\nNew version: %d.%d (%d)", SAVE_VERSION, MINOR_VERSION, BUILD_NUM, major, minor, buildnum);
|
|
|
|
}
|
2011-08-19 17:44:09 -05:00
|
|
|
#endif
|
|
|
|
if (confirm_ui(vid_buf, "Do you want to update The Powder Toy?", tmp, "Update"))
|
|
|
|
{
|
|
|
|
free(tmp);
|
|
|
|
tmp = download_ui(vid_buf, my_uri, &i);
|
|
|
|
if (tmp)
|
|
|
|
{
|
|
|
|
save_presets(1);
|
|
|
|
if (update_start(tmp, i))
|
|
|
|
{
|
|
|
|
update_cleanup();
|
|
|
|
save_presets(0);
|
|
|
|
error_ui(vid_buf, 0, "Update failed - try downloading a new version.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-10-24 16:04:58 -05:00
|
|
|
{
|
2011-08-19 17:44:09 -05:00
|
|
|
free(tmp);
|
2011-10-24 16:04:58 -05:00
|
|
|
old_version = 0;
|
|
|
|
}
|
2011-08-19 17:44:09 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (y>=sdl_scale*(YRES+(MENUSIZE-20))) //mouse checks for buttons at the bottom, to draw mouseover texts
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (x>=189*sdl_scale && x<=202*sdl_scale && svf_login && svf_open && svf_myvote==0)
|
|
|
|
{
|
|
|
|
db = svf_own ? 275 : 272;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0)
|
|
|
|
{
|
|
|
|
db = svf_own ? 275 : 272;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=189 && x<=217 && svf_login && svf_open && svf_myvote!=0)
|
|
|
|
{
|
|
|
|
db = (svf_myvote==1) ? 273 : 274;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=219*sdl_scale && x<=((XRES+BARSIZE-(510-349))*sdl_scale) && svf_login && svf_open)
|
|
|
|
{
|
|
|
|
db = svf_own ? 257 : 256;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=((XRES+BARSIZE-(510-351))*sdl_scale) && x<((XRES+BARSIZE-(510-366))*sdl_scale))
|
|
|
|
{
|
|
|
|
db = 270;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=((XRES+BARSIZE-(510-367))*sdl_scale) && x<((XRES+BARSIZE-(510-383))*sdl_scale))
|
|
|
|
{
|
|
|
|
db = 266;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
2011-06-14 09:13:27 -05:00
|
|
|
else if (x>=37*sdl_scale && x<=187*sdl_scale)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-06-14 09:13:27 -05:00
|
|
|
if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
|
|
|
|
{
|
|
|
|
db = 277;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if(svf_login)
|
|
|
|
{
|
|
|
|
db = 259;
|
|
|
|
if (svf_open && svf_own && x<=55*sdl_scale)
|
|
|
|
db = 258;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
else if (x>=((XRES+BARSIZE-(510-385))*sdl_scale) && x<=((XRES+BARSIZE-(510-476))*sdl_scale))
|
|
|
|
{
|
|
|
|
db = svf_login ? 261 : 260;
|
|
|
|
if (svf_admin)
|
|
|
|
{
|
|
|
|
db = 268;
|
|
|
|
}
|
|
|
|
else if (svf_mod)
|
|
|
|
{
|
|
|
|
db = 271;
|
|
|
|
}
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=sdl_scale && x<=17*sdl_scale)
|
|
|
|
{
|
2011-06-14 09:13:27 -05:00
|
|
|
if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
|
|
|
|
db = 276;
|
|
|
|
else
|
|
|
|
db = 262;
|
2011-04-08 09:28:57 -05:00
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=((XRES+BARSIZE-(510-494))*sdl_scale) && x<=((XRES+BARSIZE-(510-509))*sdl_scale))
|
|
|
|
{
|
|
|
|
db = sys_pause ? 264 : 263;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=((XRES+BARSIZE-(510-476))*sdl_scale) && x<=((XRES+BARSIZE-(510-491))*sdl_scale))
|
|
|
|
{
|
|
|
|
db = 267;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (x>=19*sdl_scale && x<=35*sdl_scale && svf_open)
|
|
|
|
{
|
|
|
|
db = 265;
|
|
|
|
if (da < 51)
|
|
|
|
da ++;
|
|
|
|
}
|
|
|
|
else if (da > 0)
|
|
|
|
da --;
|
2011-03-29 17:16:54 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (da > 0)//fade away mouseover text
|
|
|
|
da --;
|
|
|
|
|
2011-04-17 14:34:54 -05:00
|
|
|
if (dae > 0) //Fade away selected elements
|
|
|
|
dae --;
|
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
if (!sdl_zoom_trig && zoom_en==1)
|
|
|
|
zoom_en = 0;
|
|
|
|
|
|
|
|
if (sdl_key=='z' && zoom_en==2 && sys_shortcuts==1)
|
|
|
|
zoom_en = 1;
|
|
|
|
|
|
|
|
if (load_mode)
|
2011-03-29 17:16:54 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
load_x = CELL*((mx/sdl_scale-load_w/2+CELL/2)/CELL);
|
|
|
|
load_y = CELL*((my/sdl_scale-load_h/2+CELL/2)/CELL);
|
|
|
|
if (load_x+load_w>XRES) load_x=XRES-load_w;
|
|
|
|
if (load_y+load_h>YRES) load_y=YRES-load_h;
|
|
|
|
if (load_x<0) load_x=0;
|
|
|
|
if (load_y<0) load_y=0;
|
|
|
|
if (bq==1 && !b)
|
|
|
|
{
|
2011-12-29 20:06:31 -06:00
|
|
|
parse_save(load_data, load_size, 0, load_x, load_y, bmap, vx, vy, pv, fvx, fvy, signs, parts, pmap);
|
2011-04-08 09:28:57 -05:00
|
|
|
free(load_data);
|
|
|
|
free(load_img);
|
|
|
|
load_mode = 0;
|
|
|
|
}
|
|
|
|
else if (bq==4 && !b)
|
|
|
|
{
|
|
|
|
free(load_data);
|
|
|
|
free(load_img);
|
|
|
|
load_mode = 0;
|
|
|
|
}
|
2011-03-29 17:16:54 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (save_mode==1)//getting the area you are selecting
|
2011-03-29 17:16:54 -05:00
|
|
|
{
|
2011-08-23 09:39:40 -05:00
|
|
|
save_x = mx/sdl_scale;
|
|
|
|
save_y = my/sdl_scale;
|
|
|
|
if (save_x >= XRES) save_x = XRES-1;
|
|
|
|
if (save_y >= YRES) save_y = YRES-1;
|
2011-04-08 09:28:57 -05:00
|
|
|
save_w = 1;
|
|
|
|
save_h = 1;
|
|
|
|
if (b==1)
|
|
|
|
{
|
|
|
|
save_mode = 2;
|
|
|
|
}
|
|
|
|
else if (b==4)
|
|
|
|
{
|
|
|
|
save_mode = 0;
|
|
|
|
copy_mode = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (save_mode==2)
|
|
|
|
{
|
2011-09-05 17:47:10 -05:00
|
|
|
save_w = mx/sdl_scale + 1 - save_x;
|
|
|
|
save_h = my/sdl_scale + 1 - save_y;
|
2011-08-23 09:39:40 -05:00
|
|
|
if (save_w+save_x>XRES) save_w = XRES-save_x;
|
|
|
|
if (save_h+save_y>YRES) save_h = YRES-save_y;
|
2011-04-08 09:28:57 -05:00
|
|
|
if (save_w<1) save_w = 1;
|
|
|
|
if (save_h<1) save_h = 1;
|
|
|
|
if (!b)
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (copy_mode==1)//CTRL-C, copy
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-12-29 20:06:31 -06:00
|
|
|
clipboard_data=build_save(&clipboard_length, save_x, save_y, save_w, save_h, bmap, vx, vy, pv, fvx, fvy, signs, parts);
|
2011-04-08 09:28:57 -05:00
|
|
|
clipboard_ready = 1;
|
|
|
|
save_mode = 0;
|
|
|
|
copy_mode = 0;
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (copy_mode==2)//CTRL-X, cut
|
2011-01-28 17:54:50 -06:00
|
|
|
{
|
2011-12-29 20:06:31 -06:00
|
|
|
clipboard_data=build_save(&clipboard_length, save_x, save_y, save_w, save_h, bmap, vx, vy, pv, fvx, fvy, signs, parts);
|
2011-04-08 09:28:57 -05:00
|
|
|
clipboard_ready = 1;
|
|
|
|
save_mode = 0;
|
|
|
|
copy_mode = 0;
|
2011-08-23 09:39:40 -05:00
|
|
|
clear_area(save_x, save_y, save_w, save_h);
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else//normal save
|
2011-01-31 12:12:29 -06:00
|
|
|
{
|
2011-08-23 09:39:40 -05:00
|
|
|
stamp_save(save_x, save_y, save_w, save_h);
|
2011-04-08 09:28:57 -05:00
|
|
|
save_mode = 0;
|
2011-01-31 12:12:29 -06:00
|
|
|
}
|
2011-01-28 17:54:50 -06:00
|
|
|
}
|
2011-02-24 12:04:08 -06:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else if (sdl_zoom_trig && zoom_en<2)
|
2011-02-24 12:04:08 -06:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
x /= sdl_scale;
|
|
|
|
y /= sdl_scale;
|
|
|
|
x -= ZSIZE/2;
|
|
|
|
y -= ZSIZE/2;
|
|
|
|
if (x<0) x=0;
|
|
|
|
if (y<0) y=0;
|
|
|
|
if (x>XRES-ZSIZE) x=XRES-ZSIZE;
|
|
|
|
if (y>YRES-ZSIZE) y=YRES-ZSIZE;
|
|
|
|
zoom_x = x;
|
|
|
|
zoom_y = y;
|
|
|
|
zoom_wx = (x<XRES/2) ? XRES-ZSIZE*ZFACTOR : 0;
|
|
|
|
zoom_wy = 0;
|
|
|
|
zoom_en = 1;
|
|
|
|
if (!b && bq)
|
2011-08-27 07:14:20 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
zoom_en = 2;
|
2011-08-27 07:14:20 -05:00
|
|
|
sdl_zoom_trig = 0;
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
else if (b)//there is a click
|
|
|
|
{
|
|
|
|
if (it > 50)
|
|
|
|
it = 50;
|
|
|
|
x /= sdl_scale;
|
|
|
|
y /= sdl_scale;
|
|
|
|
if (y>=YRES+(MENUSIZE-20))//check if mouse is on menu buttons
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (!lb)//mouse is NOT held down, so it is a first click
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (x>=189 && x<=202 && svf_login && svf_open && svf_myvote==0 && svf_own==0)
|
|
|
|
{
|
|
|
|
if (execute_vote(vid_buf, svf_id, "Up"))
|
|
|
|
{
|
|
|
|
svf_myvote = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x>=204 && x<=217 && svf_login && svf_open && svf_myvote==0 && svf_own==0)
|
|
|
|
{
|
|
|
|
if (execute_vote(vid_buf, svf_id, "Down"))
|
|
|
|
{
|
|
|
|
svf_myvote = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x>=219 && x<=(XRES+BARSIZE-(510-349)) && svf_login && svf_open)
|
|
|
|
tag_list_ui(vid_buf);
|
|
|
|
if (x>=(XRES+BARSIZE-(510-351)) && x<(XRES+BARSIZE-(510-366)) && !bq)
|
|
|
|
{
|
2011-04-25 10:39:28 -05:00
|
|
|
//legacy_enable = !legacy_enable;
|
|
|
|
simulation_ui(vid_buf);
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
if (x>=(XRES+BARSIZE-(510-367)) && x<=(XRES+BARSIZE-(510-383)) && !bq)
|
|
|
|
{
|
|
|
|
clear_sim();
|
|
|
|
for (i=0; i<NPART-1; i++)
|
|
|
|
parts[i].life = i+1;
|
|
|
|
parts[NPART-1].life = -1;
|
|
|
|
pfree = 0;
|
|
|
|
|
|
|
|
legacy_enable = 0;
|
2011-06-25 10:59:25 -05:00
|
|
|
svf_filename[0] = 0;
|
|
|
|
svf_fileopen = 0;
|
2011-04-08 09:28:57 -05:00
|
|
|
svf_myvote = 0;
|
|
|
|
svf_open = 0;
|
|
|
|
svf_publish = 0;
|
|
|
|
svf_own = 0;
|
|
|
|
svf_id[0] = 0;
|
|
|
|
svf_name[0] = 0;
|
|
|
|
svf_tags[0] = 0;
|
|
|
|
svf_description[0] = 0;
|
|
|
|
gravityMode = 0;
|
|
|
|
airMode = 0;
|
|
|
|
}
|
|
|
|
if (x>=(XRES+BARSIZE-(510-385)) && x<=(XRES+BARSIZE-(510-476)))
|
|
|
|
{
|
|
|
|
login_ui(vid_buf);
|
|
|
|
if (svf_login) {
|
|
|
|
save_presets(0);
|
|
|
|
http_session_check = NULL;
|
|
|
|
}
|
|
|
|
}
|
2011-06-14 09:13:27 -05:00
|
|
|
if(sdl_mod & (KMOD_LCTRL|KMOD_RCTRL))
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-06-14 09:13:27 -05:00
|
|
|
if (x>=37 && x<=187)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-06-14 09:13:27 -05:00
|
|
|
save_filename_ui(vid_buf);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (x>=1 && x<=17)
|
|
|
|
{
|
|
|
|
catalogue_ui(vid_buf);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (x>=37 && x<=187 && svf_login)
|
|
|
|
{
|
|
|
|
if (!svf_open || !svf_own || x>51)
|
|
|
|
{
|
|
|
|
if (save_name_ui(vid_buf)) {
|
|
|
|
execute_save(vid_buf);
|
|
|
|
if (svf_id[0]) {
|
|
|
|
copytext_ui(vid_buf, "Save ID", "Saved successfully!", svf_id);
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
}
|
2011-06-14 09:13:27 -05:00
|
|
|
else
|
|
|
|
execute_save(vid_buf);
|
|
|
|
while (!sdl_poll())
|
|
|
|
if (!SDL_GetMouseState(&x, &y))
|
|
|
|
break;
|
|
|
|
b = bq = 0;
|
|
|
|
}
|
|
|
|
if (x>=1 && x<=17)
|
|
|
|
{
|
|
|
|
search_ui(vid_buf);
|
|
|
|
memset(pers_bg, 0, (XRES+BARSIZE)*YRES*PIXELSIZE);
|
|
|
|
memset(fire_r, 0, sizeof(fire_r));
|
|
|
|
memset(fire_g, 0, sizeof(fire_g));
|
|
|
|
memset(fire_b, 0, sizeof(fire_b));
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
}
|
2011-06-25 10:59:25 -05:00
|
|
|
if (x>=19 && x<=35 && svf_last && (svf_open || svf_fileopen) && !bq) {
|
2011-04-08 09:28:57 -05:00
|
|
|
//int tpval = sys_pause;
|
2011-12-29 20:06:31 -06:00
|
|
|
parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, vx, vy, pv, fvx, fvy, signs, parts, pmap);
|
2011-04-08 09:28:57 -05:00
|
|
|
//sys_pause = tpval;
|
|
|
|
}
|
|
|
|
if (x>=(XRES+BARSIZE-(510-476)) && x<=(XRES+BARSIZE-(510-491)) && !bq)
|
|
|
|
{
|
2012-03-14 20:03:00 -05:00
|
|
|
render_ui(vid_buf, XRES+BARSIZE-(510-491), YRES-2, 3);
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
if (x>=(XRES+BARSIZE-(510-494)) && x<=(XRES+BARSIZE-(510-509)) && !bq)
|
|
|
|
sys_pause = !sys_pause;
|
|
|
|
lb = 0;
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
|
|
|
}
|
2012-02-03 19:05:38 -06:00
|
|
|
else if (y<YRES && x<XRES)// mouse is in playing field
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
int signi;
|
2011-04-08 05:09:42 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
c = (b&1) ? sl : sr; //c is element to be spawned
|
|
|
|
su = c;
|
|
|
|
|
2011-08-29 11:47:22 -05:00
|
|
|
if (c!=WL_SIGN+100 && c!=PT_FIGH)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
if (!bq)
|
|
|
|
for (signi=0; signi<MAXSIGNS; signi++)
|
|
|
|
if (sregexp(signs[signi].text, "^{c:[0-9]*|.*}$")==0)
|
|
|
|
{
|
|
|
|
int signx, signy, signw, signh;
|
|
|
|
get_sign_pos(signi, &signx, &signy, &signw, &signh);
|
|
|
|
if (x>=signx && x<=signx+signw && y>=signy && y<=signy+signh)
|
|
|
|
{
|
|
|
|
char buff[256];
|
|
|
|
int sldr;
|
2011-01-28 17:54:50 -06:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
memset(buff, 0, sizeof(buff));
|
2011-04-08 05:09:42 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
for (sldr=3; signs[signi].text[sldr] != '|'; sldr++)
|
|
|
|
buff[sldr-3] = signs[signi].text[sldr];
|
2011-04-08 05:09:42 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
buff[sldr-3] = '\0';
|
|
|
|
open_ui(vid_buf, buff, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-08 05:09:42 -05:00
|
|
|
|
2012-04-28 18:34:56 -05:00
|
|
|
if (c==WL_SIGN+100 || MSIGN!=-1) // if sign tool is selected or a sign is being moved
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (!bq)
|
|
|
|
add_sign_ui(vid_buf, x, y);
|
|
|
|
}
|
2011-12-28 16:15:55 -06:00
|
|
|
else if (c==PT_FIGH)
|
2011-08-29 11:47:22 -05:00
|
|
|
{
|
|
|
|
if (!bq)
|
|
|
|
create_part(-1, x, y, PT_FIGH);
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
//for the click functions, lx and ly, are the positions of where the FIRST click happened. x,y are current mouse position.
|
|
|
|
else if (lb)//lb means you are holding mouse down
|
|
|
|
{
|
|
|
|
if (lm == 1)//line tool
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-07-12 03:35:55 -05:00
|
|
|
if (sdl_mod & KMOD_ALT)
|
|
|
|
{
|
|
|
|
float snap_angle = floor(atan2(y-ly, x-lx)/(M_PI*0.25)+0.5)*M_PI*0.25;
|
|
|
|
float line_mag = sqrtf(pow(x-lx,2)+pow(y-ly,2));
|
|
|
|
line_x = (int)(line_mag*cos(snap_angle)+lx+0.5f);
|
|
|
|
line_y = (int)(line_mag*sin(snap_angle)+ly+0.5f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
line_x = x;
|
|
|
|
line_y = y;
|
|
|
|
}
|
|
|
|
xor_line(lx, ly, line_x, line_y, vid_buf);
|
2011-04-08 09:28:57 -05:00
|
|
|
if (c==WL_FAN+100 && lx>=0 && ly>=0 && lx<XRES && ly<YRES && bmap[ly/CELL][lx/CELL]==WL_FAN)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-07-12 03:35:55 -05:00
|
|
|
nfvx = (line_x-lx)*0.005f;
|
|
|
|
nfvy = (line_y-ly)*0.005f;
|
2011-08-20 14:41:39 -05:00
|
|
|
flood_parts(lx, ly, WL_FANHELPER, -1, WL_FAN, 0);
|
2011-04-08 09:28:57 -05:00
|
|
|
for (j=0; j<YRES/CELL; j++)
|
|
|
|
for (i=0; i<XRES/CELL; i++)
|
|
|
|
if (bmap[j][i] == WL_FANHELPER)
|
|
|
|
{
|
|
|
|
fvx[j][i] = nfvx;
|
|
|
|
fvy[j][i] = nfvy;
|
|
|
|
bmap[j][i] = WL_FAN;
|
|
|
|
}
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-05-11 15:29:35 -05:00
|
|
|
if (c == SPC_WIND)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
for (j=-bsy; j<=bsy; j++)
|
|
|
|
for (i=-bsx; i<=bsx; i++)
|
2011-07-12 13:06:59 -05:00
|
|
|
if (lx+i>0 && ly+j>0 && lx+i<XRES && ly+j<YRES && InCurrentBrush(i,j,bsx,bsy))
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-07-12 03:35:55 -05:00
|
|
|
vx[(ly+j)/CELL][(lx+i)/CELL] += (line_x-lx)*0.002f;
|
|
|
|
vy[(ly+j)/CELL][(lx+i)/CELL] += (line_y-ly)*0.002f;
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lm == 2)//box tool
|
|
|
|
{
|
|
|
|
xor_line(lx, ly, lx, y, vid_buf);
|
|
|
|
xor_line(lx, y, x, y, vid_buf);
|
|
|
|
xor_line(x, y, x, ly, vid_buf);
|
|
|
|
xor_line(x, ly, lx, ly, vid_buf);
|
|
|
|
}
|
|
|
|
else//while mouse is held down, it draws lines between previous and current positions
|
|
|
|
{
|
2011-05-11 15:29:35 -05:00
|
|
|
if (c == SPC_WIND)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
for (j=-bsy; j<=bsy; j++)
|
|
|
|
for (i=-bsx; i<=bsx; i++)
|
2011-07-12 10:28:33 -05:00
|
|
|
if (x+i>0 && y+j>0 && x+i<XRES && y+j<YRES && InCurrentBrush(i,j,bsx,bsy))
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
vx[(y+j)/CELL][(x+i)/CELL] += (x-lx)*0.01f;
|
|
|
|
vy[(y+j)/CELL][(x+i)/CELL] += (y-ly)*0.01f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-08-20 14:41:39 -05:00
|
|
|
create_line(lx, ly, x, y, bsx, bsy, c, get_brush_flags());
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
lx = x;
|
|
|
|
ly = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else //it is the first click
|
|
|
|
{
|
|
|
|
//start line tool
|
2011-07-12 03:35:55 -05:00
|
|
|
if ((sdl_mod & (KMOD_SHIFT)) && !(sdl_mod & (KMOD_CTRL)))
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
lx = x;
|
|
|
|
ly = y;
|
|
|
|
lb = b;
|
|
|
|
lm = 1;//line
|
|
|
|
}
|
|
|
|
//start box tool
|
2011-07-12 03:35:55 -05:00
|
|
|
else if ((sdl_mod & (KMOD_CTRL)) && !(sdl_mod & (KMOD_SHIFT|KMOD_ALT)))
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
lx = x;
|
|
|
|
ly = y;
|
|
|
|
lb = b;
|
|
|
|
lm = 2;//box
|
|
|
|
}
|
|
|
|
//flood fill
|
2011-07-12 03:35:55 -05:00
|
|
|
else if ((sdl_mod & (KMOD_CTRL)) && (sdl_mod & (KMOD_SHIFT)) && !(sdl_mod & (KMOD_ALT)))
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
if (sdl_mod & (KMOD_CAPS))
|
|
|
|
c = 0;
|
2011-08-16 17:07:12 -05:00
|
|
|
if (c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE&&c!=SPC_WIND&&c!=SPC_PGRV&&c!=SPC_NGRV)
|
2011-08-20 14:41:39 -05:00
|
|
|
flood_parts(x, y, c, -1, -1, get_brush_flags());
|
2011-04-08 09:28:57 -05:00
|
|
|
if (c==SPC_HEAT || c==SPC_COOL)
|
2012-03-14 18:20:27 -05:00
|
|
|
create_parts(x, y, bsx, bsy, c, get_brush_flags(), 1);
|
2011-04-08 09:28:57 -05:00
|
|
|
lx = x;
|
|
|
|
ly = y;
|
|
|
|
lb = 0;
|
|
|
|
lm = 0;
|
|
|
|
}
|
|
|
|
//sample
|
2011-07-12 03:35:55 -05:00
|
|
|
else if (((sdl_mod & (KMOD_ALT)) && !(sdl_mod & (KMOD_SHIFT|KMOD_CTRL))) || b==SDL_BUTTON_MIDDLE)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-04-27 16:51:20 -05:00
|
|
|
if (y>=0 && y<YRES && x>=0 && x<XRES)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
|
|
|
int cr;
|
|
|
|
cr = pmap[y][x];
|
2011-08-24 10:35:52 -05:00
|
|
|
if (!cr)
|
2011-04-27 16:51:20 -05:00
|
|
|
cr = photons[y][x];
|
2011-08-24 10:35:52 -05:00
|
|
|
if (cr)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
c = sl = cr&0xFF;
|
2011-07-25 14:04:41 -05:00
|
|
|
if (c==PT_LIFE)
|
|
|
|
c = sl = (parts[cr>>8].ctype << 8) | c;
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Something
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
lx = x;
|
|
|
|
ly = y;
|
|
|
|
lb = 0;
|
|
|
|
lm = 0;
|
|
|
|
}
|
|
|
|
else //normal click, spawn element
|
|
|
|
{
|
|
|
|
//Copy state before drawing any particles (for undo)7
|
|
|
|
int cbx, cby, cbi;
|
2011-04-08 05:09:42 -05:00
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
for (cbi=0; cbi<NPART; cbi++)
|
|
|
|
cb_parts[cbi] = parts[cbi];
|
|
|
|
|
|
|
|
for (cby = 0; cby<YRES; cby++)
|
|
|
|
for (cbx = 0; cbx<XRES; cbx++)
|
|
|
|
cb_pmap[cby][cbx] = pmap[cby][cbx];
|
|
|
|
|
|
|
|
for (cby = 0; cby<(YRES/CELL); cby++)
|
|
|
|
for (cbx = 0; cbx<(XRES/CELL); cbx++)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
cb_vx[cby][cbx] = vx[cby][cbx];
|
|
|
|
cb_vy[cby][cbx] = vy[cby][cbx];
|
|
|
|
cb_pv[cby][cbx] = pv[cby][cbx];
|
2011-06-18 06:19:47 -05:00
|
|
|
cb_hv[cby][cbx] = hv[cby][cbx];
|
2011-04-08 09:28:57 -05:00
|
|
|
cb_bmap[cby][cbx] = bmap[cby][cbx];
|
|
|
|
cb_emap[cby][cbx] = emap[cby][cbx];
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2012-03-14 18:20:27 -05:00
|
|
|
create_parts(x, y, bsx, bsy, c, get_brush_flags(), 1);
|
2011-04-08 09:28:57 -05:00
|
|
|
lx = x;
|
|
|
|
ly = y;
|
|
|
|
lb = b;
|
|
|
|
lm = 0;
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (lb && lm) //lm is box/line tool
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
x /= sdl_scale;
|
|
|
|
y /= sdl_scale;
|
|
|
|
c = (lb&1) ? sl : sr;
|
|
|
|
su = c;
|
|
|
|
if (lm == 1)//line
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (c!=WL_FAN+100 || lx<0 || ly<0 || lx>=XRES || ly>=YRES || bmap[ly/CELL][lx/CELL]!=WL_FAN)
|
2011-08-20 14:41:39 -05:00
|
|
|
create_line(lx, ly, line_x, line_y, bsx, bsy, c, get_brush_flags());
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else//box
|
2011-08-20 14:41:39 -05:00
|
|
|
create_box(lx, ly, x, y, c, get_brush_flags());
|
2011-04-08 09:28:57 -05:00
|
|
|
lm = 0;
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
lb = 0;
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
|
|
|
|
if (load_mode)//draw preview of stamp
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
draw_image(vid_buf, load_img, load_x, load_y, load_w, load_h, 128);
|
|
|
|
xor_rect(vid_buf, load_x, load_y, load_w, load_h);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
|
|
|
|
if (save_mode)//draw dotted lines for selection
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-08-23 09:39:40 -05:00
|
|
|
xor_rect(vid_buf, save_x, save_y, save_w, save_h);
|
2011-04-08 09:28:57 -05:00
|
|
|
da = 51;//draws mouseover text for the message
|
|
|
|
db = 269;//the save message
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
|
|
|
|
if (zoom_en!=1 && !load_mode && !save_mode)//draw normal cursor
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
render_cursor(vid_buf, mx/sdl_scale, my/sdl_scale, su, bsx, bsy);
|
|
|
|
mousex = mx/sdl_scale;
|
|
|
|
mousey = my/sdl_scale;
|
|
|
|
}
|
2011-11-08 06:35:07 -06:00
|
|
|
#ifdef OGLR
|
|
|
|
draw_parts_fbo();
|
|
|
|
#endif
|
2011-04-08 09:28:57 -05:00
|
|
|
if (zoom_en)
|
|
|
|
render_zoom(vid_buf);
|
|
|
|
|
|
|
|
if (da)
|
|
|
|
switch (db)//various mouseover messages, da is the alpha
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
case 256:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Add simulation tags.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 257:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Add and remove simulation tags.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 258:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Save the simulation under the current name.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 259:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Save the simulation under a new name.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 260:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Sign into the Simulation Server.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 261:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Sign into the Simulation Server under a new name.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 262:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Find & open a simulation", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 263:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Pause the simulation", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 264:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Resume the simulation", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 265:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Reload the simulation", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 266:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Erase all particles and walls", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 267:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Change display mode", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 268:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Annuit C\245ptis", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 269:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Click-and-drag to specify a rectangle to copy (right click = cancel).", 255, 216, 32, da*5);
|
|
|
|
break;
|
|
|
|
case 270:
|
2011-05-21 05:25:19 -05:00
|
|
|
drawtext(vid_buf, 16, YRES-24, "Simulation options", 255, 255, 255, da*5);
|
2011-04-08 09:28:57 -05:00
|
|
|
break;
|
|
|
|
case 271:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "You're a moderator", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 272:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Like/Dislike this save.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 273:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "You like this.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 274:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "You dislike this.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 275:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "You cannot vote on your own save.", 255, 255, 255, da*5);
|
|
|
|
break;
|
2011-06-14 09:13:27 -05:00
|
|
|
case 276:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Open a simulation from your hard drive.", 255, 255, 255, da*5);
|
|
|
|
break;
|
|
|
|
case 277:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, "Save the simulation to your hard drive.", 255, 255, 255, da*5);
|
|
|
|
break;
|
2011-04-08 09:28:57 -05:00
|
|
|
default:
|
|
|
|
drawtext(vid_buf, 16, YRES-24, (char *)ptypes[db].descs, 255, 255, 255, da*5);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (itc)//message in the middle of the screen, such as view mode changes
|
|
|
|
{
|
|
|
|
itc--;
|
2011-09-24 10:57:01 -05:00
|
|
|
drawtext_outline(vid_buf, (XRES-textwidth(itc_msg))/2, ((YRES/2)-10), itc_msg, 255, 255, 255, itc>51?255:itc*5, 0, 0, 0, itc>51?255:itc*5);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (it)//intro message
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
it--;
|
|
|
|
drawtext(vid_buf, 16, 20, it_msg, 255, 255, 255, it>51?255:it*5);
|
|
|
|
}
|
|
|
|
|
2011-08-19 17:44:09 -05:00
|
|
|
if (old_version)
|
|
|
|
{
|
|
|
|
clearrect(vid_buf, XRES-21-old_ver_len, YRES-24, old_ver_len+9, 17);
|
|
|
|
if (is_beta)
|
|
|
|
{
|
|
|
|
drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg_beta, 255, 216, 32, 255);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
drawtext(vid_buf, XRES-16-old_ver_len, YRES-19, old_ver_msg, 255, 216, 32, 255);
|
|
|
|
}
|
|
|
|
drawrect(vid_buf, XRES-19-old_ver_len, YRES-22, old_ver_len+5, 13, 255, 216, 32, 255);
|
|
|
|
}
|
|
|
|
|
2011-05-16 06:46:08 -05:00
|
|
|
if (svf_messages)
|
|
|
|
{
|
2011-05-19 02:08:59 -05:00
|
|
|
sprintf(new_message_msg, "You have %d new message%s, Click to view", svf_messages, (svf_messages>1)?"s":"");
|
2011-05-16 06:46:08 -05:00
|
|
|
new_message_len = textwidth(new_message_msg);
|
|
|
|
|
2011-05-19 02:08:59 -05:00
|
|
|
clearrect(vid_buf, XRES-21-new_message_len, YRES-39, new_message_len+9, 17);
|
|
|
|
drawtext(vid_buf, XRES-16-new_message_len, YRES-34, new_message_msg, 255, 186, 32, 255);
|
|
|
|
drawrect(vid_buf, XRES-19-new_message_len, YRES-37, new_message_len+5, 13, 255, 186, 32, 255);
|
2011-05-16 06:46:08 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
|
|
|
|
FPS++;
|
|
|
|
currentTime = SDL_GetTicks();
|
|
|
|
elapsedTime = currentTime-pastFPS;
|
2011-04-21 15:57:07 -05:00
|
|
|
if ((FPS>2 || elapsedTime>1000*2/limitFPS) && elapsedTime && FPS*1000/elapsedTime>limitFPS)
|
|
|
|
{
|
|
|
|
while (FPS*1000/elapsedTime>limitFPS)
|
|
|
|
{
|
|
|
|
SDL_Delay(1);
|
|
|
|
currentTime = SDL_GetTicks();
|
|
|
|
elapsedTime = currentTime-pastFPS;
|
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (elapsedTime>=1000)
|
|
|
|
{
|
|
|
|
FPSB = FPS;
|
|
|
|
FPS = 0;
|
|
|
|
pastFPS = currentTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hud_enable)
|
|
|
|
{
|
|
|
|
#ifdef BETA
|
2011-11-12 10:37:01 -06:00
|
|
|
sprintf(uitext, "Beta Build %d FPS:%d Parts:%d Gravity:%d Air:%d", BUILD_NUM, FPSB, NUM_PARTS, gravityMode, airMode);
|
2011-04-08 09:28:57 -05:00
|
|
|
#else
|
|
|
|
if (DEBUG_MODE)
|
2011-11-12 10:37:01 -06:00
|
|
|
sprintf(uitext, "Build %d FPS:%d Parts:%d Gravity:%d Air:%d", BUILD_NUM, FPSB, NUM_PARTS, gravityMode, airMode);
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-12-24 14:31:29 -06:00
|
|
|
sprintf(uitext, "FPS:%d", FPSB);
|
2011-04-08 09:28:57 -05:00
|
|
|
#endif
|
|
|
|
if (REPLACE_MODE)
|
|
|
|
strappend(uitext, " [REPLACE MODE]");
|
|
|
|
if (sdl_mod&(KMOD_CAPS))
|
|
|
|
strappend(uitext, " [CAP LOCKS]");
|
|
|
|
if (GRID_MODE)
|
2011-11-03 08:24:20 -05:00
|
|
|
{
|
|
|
|
char gridtext[15];
|
|
|
|
sprintf(gridtext, " [GRID: %d]", GRID_MODE);
|
|
|
|
strappend(uitext, gridtext);
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
#ifdef INTERNAL
|
|
|
|
if (vs)
|
|
|
|
strappend(uitext, " [FRAME CAPTURE]");
|
|
|
|
#endif
|
2011-10-22 13:39:24 -05:00
|
|
|
quickoptions_tooltip_fade_invert = 255 - (quickoptions_tooltip_fade*20);
|
2011-10-24 12:43:45 -05:00
|
|
|
it_invert = 50 - it;
|
|
|
|
if(it_invert < 0)
|
|
|
|
it_invert = 0;
|
|
|
|
if(it_invert > 50)
|
|
|
|
it_invert = 50;
|
2011-04-08 09:28:57 -05:00
|
|
|
if (sdl_zoom_trig||zoom_en)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
if (zoom_x<XRES/2)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-10-22 13:39:24 -05:00
|
|
|
fillrect(vid_buf, XRES-20-textwidth(heattext), 266, textwidth(heattext)+8, 15, 0, 0, 0, quickoptions_tooltip_fade_invert*0.5);
|
|
|
|
drawtext(vid_buf, XRES-16-textwidth(heattext), 270, heattext, 255, 255, 255, quickoptions_tooltip_fade_invert*0.75);
|
2011-04-08 09:28:57 -05:00
|
|
|
if (DEBUG_MODE)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-10-22 13:39:24 -05:00
|
|
|
fillrect(vid_buf, XRES-20-textwidth(coordtext), 280, textwidth(coordtext)+8, 13, 0, 0, 0, quickoptions_tooltip_fade_invert*0.5);
|
|
|
|
drawtext(vid_buf, XRES-16-textwidth(coordtext), 282, coordtext, 255, 255, 255, quickoptions_tooltip_fade_invert*0.75);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (wavelength_gfx)
|
|
|
|
draw_wavelengths(vid_buf,XRES-20-textwidth(heattext),265,2,wavelength_gfx);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-10-22 13:39:24 -05:00
|
|
|
fillrect(vid_buf, 12, 266, textwidth(heattext)+8, 15, 0, 0, 0, quickoptions_tooltip_fade_invert*0.5);
|
|
|
|
drawtext(vid_buf, 16, 270, heattext, 255, 255, 255, quickoptions_tooltip_fade_invert*0.75);
|
2011-04-08 09:28:57 -05:00
|
|
|
if (DEBUG_MODE)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-10-22 13:39:24 -05:00
|
|
|
fillrect(vid_buf, 12, 280, textwidth(coordtext)+8, 13, 0, 0, 0, quickoptions_tooltip_fade_invert*0.5);
|
|
|
|
drawtext(vid_buf, 16, 282, coordtext, 255, 255, 255, quickoptions_tooltip_fade_invert*0.75);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (wavelength_gfx)
|
|
|
|
draw_wavelengths(vid_buf,12,265,2,wavelength_gfx);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-10-22 13:39:24 -05:00
|
|
|
fillrect(vid_buf, XRES-20-textwidth(heattext), 12, textwidth(heattext)+8, 15, 0, 0, 0, quickoptions_tooltip_fade_invert*0.5);
|
|
|
|
drawtext(vid_buf, XRES-16-textwidth(heattext), 16, heattext, 255, 255, 255, quickoptions_tooltip_fade_invert*0.75);
|
2011-04-08 09:28:57 -05:00
|
|
|
if (DEBUG_MODE)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-10-22 13:39:24 -05:00
|
|
|
fillrect(vid_buf, XRES-20-textwidth(coordtext), 26, textwidth(coordtext)+8, 11, 0, 0, 0, quickoptions_tooltip_fade_invert*0.5);
|
|
|
|
drawtext(vid_buf, XRES-16-textwidth(coordtext), 27, coordtext, 255, 255, 255, quickoptions_tooltip_fade_invert*0.75);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
if (wavelength_gfx)
|
|
|
|
draw_wavelengths(vid_buf,XRES-20-textwidth(heattext),11,2,wavelength_gfx);
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
wavelength_gfx = 0;
|
2011-11-12 10:37:01 -06:00
|
|
|
fillrect(vid_buf, 12, 12, textwidth(uitext)+8, 15, 0, 0, 0, it_invert*2.5);
|
|
|
|
drawtext(vid_buf, 16, 16, uitext, 32, 216, 255, it_invert * 4);
|
2011-04-08 09:28:57 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (console_mode)
|
|
|
|
{
|
2011-10-26 08:55:26 -05:00
|
|
|
#ifdef LUACONSOLE
|
2011-05-30 10:22:39 -05:00
|
|
|
char *console;
|
|
|
|
sys_pause = 1;
|
|
|
|
console = console_ui(vid_buf, console_error, console_more);
|
|
|
|
console = mystrdup(console);
|
|
|
|
strcpy(console_error,"");
|
|
|
|
if (process_command_lua(vid_buf, console, console_error)==-1)
|
|
|
|
{
|
|
|
|
free(console);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
free(console);
|
|
|
|
if (!console_mode)
|
|
|
|
hud_enable = 1;
|
2011-04-08 09:28:57 -05:00
|
|
|
#else
|
|
|
|
char *console;
|
|
|
|
sys_pause = 1;
|
|
|
|
console = console_ui(vid_buf, console_error, console_more);
|
|
|
|
console = mystrdup(console);
|
|
|
|
strcpy(console_error,"");
|
|
|
|
if (process_command_old(vid_buf, console, console_error)==-1)
|
2011-04-08 05:09:42 -05:00
|
|
|
{
|
2011-04-08 09:28:57 -05:00
|
|
|
free(console);
|
|
|
|
break;
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
2011-04-08 09:28:57 -05:00
|
|
|
free(console);
|
|
|
|
if (!console_mode)
|
|
|
|
hud_enable = 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//execute python step hook
|
|
|
|
sdl_blit(0, 0, XRES+BARSIZE, YRES+MENUSIZE, vid_buf, XRES+BARSIZE);
|
|
|
|
|
|
|
|
//Setting an element for the stick man
|
2011-10-23 03:22:31 -05:00
|
|
|
if (player.spwn==0)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-10-15 11:20:54 -05:00
|
|
|
if ((sr<PT_NUM && ptypes[sr].falldown>0) || sr==SPC_AIR || sr == PT_NEUT || sr == PT_PHOT || sr == PT_LIGH)
|
2011-10-23 03:22:31 -05:00
|
|
|
player.elem = sr;
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-10-23 03:22:31 -05:00
|
|
|
player.elem = PT_DUST;
|
2011-04-08 09:28:57 -05:00
|
|
|
}
|
2011-10-23 03:22:31 -05:00
|
|
|
if (player2.spwn==0)
|
2011-04-08 09:28:57 -05:00
|
|
|
{
|
2011-10-15 11:20:54 -05:00
|
|
|
if ((sr<PT_NUM && ptypes[sr].falldown>0) || sr==SPC_AIR || sr == PT_NEUT || sr == PT_PHOT || sr == PT_LIGH)
|
2011-10-23 03:22:31 -05:00
|
|
|
player2.elem = sr;
|
2011-04-08 09:28:57 -05:00
|
|
|
else
|
2011-10-23 03:22:31 -05:00
|
|
|
player2.elem = PT_DUST;
|
2011-04-08 05:09:42 -05:00
|
|
|
}
|
|
|
|
}
|
2011-11-12 14:44:15 -06:00
|
|
|
save_presets(0);
|
|
|
|
|
2011-04-08 09:28:57 -05:00
|
|
|
SDL_CloseAudio();
|
|
|
|
http_done();
|
2011-12-10 09:23:33 -06:00
|
|
|
gravity_cleanup();
|
2011-05-30 10:22:39 -05:00
|
|
|
#ifdef LUACONSOLE
|
|
|
|
luacon_close();
|
|
|
|
#endif
|
2011-05-19 09:32:50 -05:00
|
|
|
#ifdef PTW32_STATIC_LIB
|
|
|
|
pthread_win32_thread_detach_np();
|
|
|
|
pthread_win32_process_detach_np();
|
2011-04-08 09:28:57 -05:00
|
|
|
#endif
|
|
|
|
return 0;
|
2011-04-12 06:19:21 -05:00
|
|
|
}
|
2011-04-13 15:39:46 -05:00
|
|
|
#endif
|