merge merge merge
This commit is contained in:
parent
ca1cd0da06
commit
3b048f8a06
33
Makefile
33
Makefile
@ -1,8 +1,8 @@
|
||||
SOURCES := src/*.c src/elements/*.c
|
||||
|
||||
CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -Iincludes/
|
||||
CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -Iincludes/
|
||||
OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations
|
||||
LFLAGS := -lSDL -lm -lbz2
|
||||
LFLAGS := -lSDL -lm -lbz2 -lpython2.7 -lm -L/usr/lib/python2.7/config -I/usr/include/python2.7
|
||||
LFLAGS_X := -lm -lbz2 -lSDLmain
|
||||
MFLAGS_SSE3 := -march=native -DX86 -DX86_SSE3 -msse3
|
||||
MFLAGS_SSE2 := -march=native -DX86 -DX86_SSE2 -msse2
|
||||
@ -11,67 +11,84 @@ FLAGS_DBUG := -Wall -std=c99 -D_POSIX_C_SOURCE=200112L -pg -DX86 -DX86_SSE3 -mss
|
||||
COMPILER := gcc
|
||||
LINUX_TARG := powder-64-sse2 powder-sse powder-sse2
|
||||
WIN32_TARG := powder-sse.exe powder-sse2.exe
|
||||
PYCOMMAND := python2 getheader.py
|
||||
|
||||
powder: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -DINTERNAL -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64
|
||||
mv $@ build
|
||||
powder-debug-64: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m64 -o$@ $(FLAGS_DBUG) -DLIN64 $(SOURCES) -Iincludes/
|
||||
mv $@ build
|
||||
powder-debug: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m32 -o$@ $(FLAGS_DBUG) -DLIN32 $(SOURCES) -Iincludes/
|
||||
mv $@ build
|
||||
powder-sse3: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN32
|
||||
strip $@
|
||||
mv $@ build
|
||||
powder-sse2: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN32
|
||||
strip $@
|
||||
mv $@ build
|
||||
powder-sse: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m32 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE) $(SOURCES) -DLIN32
|
||||
strip $@
|
||||
mv $@ build
|
||||
powder-64-sse3-opengl: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64 -lGL -lGLU -DOpenGL
|
||||
strip $@
|
||||
mv $@ build
|
||||
powder-64-sse3: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE3) $(SOURCES) -DLIN64
|
||||
strip $@
|
||||
mv $@ build
|
||||
powder-64-sse2: $(SOURCES)
|
||||
$(PYCOMMAND)
|
||||
$(COMPILER) -m64 -o$@ $(CFLAGS) $(OFLAGS) $(LFLAGS) $(MFLAGS_SSE2) $(SOURCES) -DLIN64
|
||||
strip $@
|
||||
mv $@ build
|
||||
|
||||
powder-icc: $(SOURCES)
|
||||
/opt/intel/Compiler/11.1/073/bin/intel64/icc -m64 -o$@ -Iincludes/ -O2 -march=core2 -msse3 -mfpmath=sse -lSDL -lbz2 -lm -xW $(SOURCES) -std=c99 -D_POSIX_C_SOURCE=200112L
|
||||
$(PYCOMMAND)
|
||||
/opt/intel/Compiler/11.1/073/bin/intel64/icc -m64 -o$@ -Iincludes/ -O2 -march=core2 -msse3 -mfpmath=sse -lSDL -lbz2 -lm -xW $(SOURCES) -std=c99 -D_POSIX_C_SOURCE=200112L
|
||||
|
||||
powder-res.o: powder-res.rc powder.ico
|
||||
$(PYCOMMAND)
|
||||
i586-mingw32msvc-windres powder-res.rc powder-res.o
|
||||
|
||||
powder-sse3.exe: $(SOURCES) powder-res.o
|
||||
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE3) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
|
||||
$(PYCOMMAND)
|
||||
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE3) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
|
||||
strip $@
|
||||
chmod 0644 $@
|
||||
mv $@ build
|
||||
powder-sse2.exe: $(SOURCES) powder-res.o
|
||||
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE2) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
|
||||
$(PYCOMMAND)
|
||||
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE2) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
|
||||
strip $@
|
||||
chmod 0644 $@
|
||||
mv $@ build
|
||||
powder-sse.exe: $(SOURCES) powder-res.o
|
||||
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE) $(SOURCES) powder-res.o -lmingw32 -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
|
||||
$(PYCOMMAND)
|
||||
i586-mingw32msvc-gcc -o$@ $(CFLAGS) $(OFLAGS) $(MFLAGS_SSE) $(SOURCES) powder-res.o -lmingw32 -llibregex -lws2_32 -lSDLmain $(LFLAGS) -mwindows -DWIN32
|
||||
strip $@
|
||||
chmod 0644 $@
|
||||
mv $@ build
|
||||
powder-x: $(SOURCES)
|
||||
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL
|
||||
$(PYCOMMAND)
|
||||
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL -framework Python
|
||||
strip $@
|
||||
mv $@ build
|
||||
powder-x-ogl: $(SOURCES)
|
||||
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DOpenGL -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL -framework OpenGL
|
||||
$(PYCOMMAND)
|
||||
gcc -o $@ $(CFLAGS) $(OFLAGS) $(LFLAGS_X) $(MFLAGS) $(SOURCES) -DOpenGL -DMACOSX -DPIX32BGRA -arch x86_64 -framework Cocoa -framework SDL -framework OpenGL -framework Python
|
||||
strip $@
|
||||
mv $@ build
|
||||
|
211
build/ext_chat.py
Normal file
211
build/ext_chat.py
Normal file
@ -0,0 +1,211 @@
|
||||
import tpt
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
import tpt_console
|
||||
|
||||
HOST="irc.freenode.net"
|
||||
PORT=6667
|
||||
name=tpt.get_name()
|
||||
print "name is %s"%repr(name)
|
||||
if(name==""):
|
||||
#fuck. abort?
|
||||
raise SystemExit("please log in!")
|
||||
|
||||
def raw(s,st):
|
||||
s.send("%s\n\r"%st)
|
||||
|
||||
def init():
|
||||
global frame,s,rec,readbuffer,namelist,typing,typed,IDENT,NICK
|
||||
global REALNAME,CHANNEL
|
||||
frame=0
|
||||
s=None
|
||||
rec=([("",0,0,0,255)]*20)+[("connected.",255,0,0,128)]
|
||||
readbuffer=""
|
||||
namelist=[]
|
||||
typing=False
|
||||
typed=""
|
||||
NICK=name+"[tpt]"
|
||||
IDENT=name+"[tpt]"
|
||||
REALNAME=name
|
||||
CHANNEL="#foobar7"
|
||||
readbuffer=""
|
||||
|
||||
def exit():
|
||||
raw(s,"QUIT")
|
||||
s.close()
|
||||
|
||||
def console_handle(txt):
|
||||
"""
|
||||
:doxin!~lieuwe@unaffiliated/lieuwe JOIN :#foobar7
|
||||
:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG #foobar7 :there
|
||||
:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG #foobar7 :ACTION is fat
|
||||
"""
|
||||
lst=txt.split(" ")
|
||||
if(lst[0]=="/me"):
|
||||
rec.append(("%s %s"%(NICK,txt[4:]),255,0,255,128))
|
||||
raw(s,"PRIVMSG %s :\x01ACTION %s\x01"%(CHANNEL,txt[4:]))
|
||||
tpt.console_close()
|
||||
else:
|
||||
rec.append(("<%s>: %s"%(NICK,txt),255,255,0,128))
|
||||
raw(s,"PRIVMSG %s :%s"%(CHANNEL,txt))
|
||||
tpt.console_close()
|
||||
|
||||
def key(keyy) :
|
||||
try:
|
||||
a=key.pmod
|
||||
except:
|
||||
key.pmod=(False,False,False)
|
||||
global typing,typed
|
||||
print "got %s"%repr(keyy)
|
||||
ctrl1,ctrl2,alt1,alt2,shift1,shift2=tpt.get_modifier()
|
||||
mod=(ctrl1 or ctrl2,alt1 or alt2,shift1 or shift2)
|
||||
skip=False
|
||||
if(not key.pmod[0] and mod[0]):
|
||||
skip=True
|
||||
if(not key.pmod[1] and mod[1]):
|
||||
skip=True
|
||||
if(not key.pmod[2] and mod[2]):
|
||||
skip=True
|
||||
key.pmod=mod
|
||||
if(skip):
|
||||
return
|
||||
|
||||
if(typing and ord(keyy)>=32 and ord(keyy)<=126):
|
||||
if(mod[2]):
|
||||
typed+=keyy.upper()#needs to be fixed for special chars
|
||||
else:
|
||||
typed+=keyy
|
||||
if(keyy=="\x1b" and typing):
|
||||
typing=False
|
||||
typed=""
|
||||
tpt.shortcuts_enable()
|
||||
if(keyy=="t" and typing==False):
|
||||
typing=True
|
||||
tpt.shortcuts_disable()
|
||||
if(keyy=="\r" and typing==True):
|
||||
console_handle(typed)
|
||||
typed=""
|
||||
typing=False
|
||||
tpt.shortcuts_enable()
|
||||
#got '\t'
|
||||
#got '\x08'
|
||||
if(keyy=="\x08"):
|
||||
typed=typed[:-1]
|
||||
#if(keyy=="\t"):
|
||||
# startswith=
|
||||
|
||||
|
||||
def step():
|
||||
global frame,s,rec,readbuffer,namelist
|
||||
frame+=1
|
||||
if(frame==1):
|
||||
tpt.console_close()
|
||||
#lets see if we can seize the console:
|
||||
tpt_console._handle=console_handle
|
||||
if(frame==2):
|
||||
tpt.draw_fillrect(0,0,612,384,0,0,0,128)
|
||||
tpt.draw_text(32,32,"opening connection\nhold on to your pants.",255,255,255)
|
||||
if(frame==3):
|
||||
s=socket.socket()
|
||||
s.settimeout(5)
|
||||
s.connect((HOST, PORT))
|
||||
raw(s,"NICK %s" % NICK)
|
||||
raw(s,"USER %s %s bla :%s" % (IDENT, HOST, REALNAME))
|
||||
s.settimeout(0)
|
||||
if(frame==120):
|
||||
raw(s,"JOIN %s"%CHANNEL)
|
||||
rec.append(("joined",255,0,0,255))
|
||||
if(frame>=3):
|
||||
try:
|
||||
readbuffer=readbuffer+s.recv(1024)
|
||||
except IOError:
|
||||
pass
|
||||
else:
|
||||
temp=readbuffer.split("\n")
|
||||
readbuffer=temp.pop()
|
||||
|
||||
for line in temp:
|
||||
line=line.strip()
|
||||
#print repr(line)
|
||||
line=line.split()
|
||||
if(line[1]=="PRIVMSG"):
|
||||
#:doxin!~lieuwe@unaffiliated/lieuwe PRIVMSG doxin[tpt] :some shit
|
||||
frm=line[0][1:].partition("!")[0]
|
||||
msg=' '.join(line[3:])[1:]
|
||||
tmp=["<",frm,"> ",msg]
|
||||
if(msg[0]=="\x01" and msg[-1]=="\x01"):
|
||||
msg=msg[8:-1]#ACTION
|
||||
tmp=[frm," ",msg]
|
||||
if(line[2]==NICK):
|
||||
rec.append((''.join(tmp),255,255,255,255))
|
||||
else:
|
||||
rec.append((''.join(tmp),255,255,255,128))
|
||||
elif(line[0]=="PING"):
|
||||
raw(s,"PONG %s"%line[1])
|
||||
elif(line[1]=="353"):
|
||||
#:leguin.freenode.net 353 doxin[tpt] = #powder :doxin[tpt] ZebraineZ _-_Rafael_-_ doxin bildramer BlueMaxima TheRazorsEDGE raj-k webb|AP where @devast8a Merbo FrozenKnight EppyMoon EvilJStoker Mortvert SpitfireWP @frankbro Ares
|
||||
names=line[4:]
|
||||
namelist=[]
|
||||
for item in names:
|
||||
item=item.strip()
|
||||
r=255
|
||||
g=255
|
||||
b=255
|
||||
if(item[0]==":"):
|
||||
item=item[1:]
|
||||
elif(item[0]=="@"):
|
||||
g=0
|
||||
b=0
|
||||
namelist.append((item,r,g,b,128))
|
||||
elif(line[1]=="JOIN"):
|
||||
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net JOIN :#powder'
|
||||
tmp=line[0][1:].partition("!")[0]
|
||||
namelist.append((tmp,255,255,255,128))
|
||||
rec.append(("%s joined"%name,0,255,0,128))
|
||||
elif(line[1]=="PART"):
|
||||
#':savask!~savask@95-190-25-195-xdsl-dynamic.kuzbass.net PART #powder :"Leaving."'
|
||||
tmp=line[0][1:].partition("!")[0]
|
||||
msg=' '.join(line[2:])[1:]
|
||||
rem=None
|
||||
for item in namelist:
|
||||
if(item[0]==tmp or item[0]=="@"+tmp):
|
||||
rem=item
|
||||
rec.append(("%s parted: %s"%(name,msg),0,255,0,128))
|
||||
if(rem!=None):
|
||||
namelist.remove(rem)
|
||||
elif(line[1]=="NICK"):
|
||||
#:doxin!~lieuwe@unaffiliated/lieuwe NICK :d0x1n
|
||||
tmp=line[0][1:].partition("!")[0]
|
||||
rem=None
|
||||
for item in namelist:
|
||||
if(item[0]==tmp or item[0]=="@"+tmp):
|
||||
rem=item
|
||||
rec.append(("%s is now known as %s"%(name,line[2]),0,255,0,128))
|
||||
if(rem!=None):
|
||||
if(rem[0][0]=="@"):
|
||||
namelist.append(("@"+line[2][1:],rem[1],rem[2],rem[3],rem[4]))
|
||||
else:
|
||||
namelist.append((line[2][1:],rem[1],rem[2],rem[3],rem[4]))
|
||||
namelist.remove(rem)
|
||||
|
||||
|
||||
|
||||
|
||||
yy=32
|
||||
if(len(rec)>20):
|
||||
rec=rec[-20:]
|
||||
for item in rec:
|
||||
tpt.draw_text(8,yy,item[0],item[1],item[2],item[3],item[4])
|
||||
yy+=8
|
||||
if(typing):
|
||||
if(frame%30<15):
|
||||
tpt.draw_text(8,yy,typed+"|",255,255,255,255)
|
||||
else:
|
||||
tpt.draw_text(8,yy,typed,255,255,255,255)
|
||||
#print namelist
|
||||
yy=32
|
||||
for item in namelist:
|
||||
tpt.draw_text(604-tpt.get_width(item[0]),yy,item[0],item[1],item[2],item[3],item[4])
|
||||
yy+=8
|
||||
|
9
build/ext_fun.py
Normal file
9
build/ext_fun.py
Normal file
@ -0,0 +1,9 @@
|
||||
import tpt
|
||||
def init():
|
||||
pass
|
||||
def key(keyy):
|
||||
pass
|
||||
def step():
|
||||
tpt.draw_text(100,100,"FUCK YEAH!",255,255,255,255)
|
||||
def exit():
|
||||
pass
|
@ -8,7 +8,7 @@
|
||||
#endif
|
||||
|
||||
#define SAVE_VERSION 46
|
||||
#define MINOR_VERSION 3
|
||||
#define MINOR_VERSION 4
|
||||
#define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter.
|
||||
//#define BETA
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
|
||||
#define THUMB_CACHE_SIZE 256
|
||||
|
||||
//#define pyconsole
|
||||
|
||||
#define IMGCONNS 3
|
||||
#define TIMEOUT 100
|
||||
#define HTTP_TIMEOUT 10
|
||||
@ -65,6 +67,8 @@ extern unsigned char ZSIZE;
|
||||
#define SQUARE_BRUSH 1
|
||||
#define BRUSH_NUM 2
|
||||
|
||||
#define PYCONSOLE
|
||||
|
||||
#ifdef PIX16
|
||||
typedef unsigned short pixel;
|
||||
#else
|
||||
|
@ -225,7 +225,7 @@ void open_link(char *uri);
|
||||
|
||||
int report_ui(pixel *vid_buf, char *save_id);
|
||||
|
||||
char *console_ui(pixel *vid_buf, char error[255]);
|
||||
char *console_ui(pixel *vid_buf, char error[255],char console_more);
|
||||
int console_parse_coords(char *txt, int *x, int *y, char *err);
|
||||
int console_parse_type(char *txt, int *element, char *err);
|
||||
int console_parse_partref(char *txt, int *which, char *err);
|
||||
|
@ -49,15 +49,15 @@
|
||||
|
||||
|
||||
|
||||
#define PT_NONE 0
|
||||
#define PT_DUST 1
|
||||
#define PT_WATR 2
|
||||
#define PT_NONE 0
|
||||
#define PT_DUST 1
|
||||
#define PT_WATR 2
|
||||
#define PT_OIL 3
|
||||
#define PT_FIRE 4
|
||||
#define PT_STNE 5
|
||||
#define PT_LAVA 6
|
||||
#define PT_GUNP 7
|
||||
#define PT_NITR 8
|
||||
#define PT_GUNP 7
|
||||
#define PT_NITR 8
|
||||
#define PT_CLNE 9
|
||||
#define PT_GAS 10
|
||||
#define PT_PLEX 11
|
||||
@ -165,7 +165,7 @@
|
||||
#define PT_ANAR 113
|
||||
#define PT_VINE 114
|
||||
#define PT_INVIS 115
|
||||
#define PT_EQUALVEL 116//all particles equal their velocities
|
||||
#define PT_EQUALVEL 116 //all particles equal their velocities
|
||||
#define PT_SPAWN2 117
|
||||
#define PT_SPAWN 118
|
||||
#define PT_SHLD1 119
|
||||
@ -436,9 +436,9 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"YEST", PIXPACK(0xEEE0C0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 15, 0, 0, 30, 1, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Yeast, grows when warm (~37C).", ST_SOLID, TYPE_PART, &update_YEST},
|
||||
{"DYST", PIXPACK(0xBBB0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 20, 0, 0, 30, 0, 80, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Dead Yeast.", ST_SOLID, TYPE_PART, NULL},
|
||||
{"THRM", PIXPACK(0xA08090), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 211, "Thermite. Burns at extremely high temperature.", ST_SOLID, TYPE_PART, &update_THRM},
|
||||
{"GLOW", PIXPACK(0x445544), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", ST_LIQUID, TYPE_LIQUID, &update_GLOW},
|
||||
{"GLOW", PIXPACK(0x445464), 0.3f, 0.02f * CFDS, 0.98f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 2, 1, 40, SC_LIQUID, R_TEMP+20.0f+273.15f, 44, "Glow, Glows under pressure", ST_LIQUID, TYPE_LIQUID, &update_GLOW},
|
||||
{"BRCK", PIXPACK(0x808080), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Brick, breakable building material.", ST_SOLID, TYPE_SOLID|PROP_HOT_GLOW, NULL},
|
||||
{"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_SPECIAL, 0.0f, 88, "Sub-zero flame.", ST_LIQUID, TYPE_GAS, NULL},
|
||||
{"CFLM", PIXPACK(0x8080FF), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.0005f * CFDS, 1, 0, 0, 0, 1, 1, 2, SC_EXPLOSIVE, 0.0f, 88, "Sub-zero flame.", ST_LIQUID, TYPE_GAS, NULL},
|
||||
{"FIRW", PIXPACK(0xFFA040), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, -0.99f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 55, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 70, "Fireworks!", ST_SOLID, TYPE_PART, &update_FIRW},
|
||||
{"FUSE", PIXPACK(0x0A5706), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly. Ignites at somewhat high temperatures and electricity.", ST_SOLID, TYPE_SOLID, &update_FUSE},
|
||||
{"FSEP", PIXPACK(0x63AD5F), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 30, 1, 70, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Fuse Powder. See FUSE.", ST_SOLID, TYPE_PART, &update_FSEP},
|
||||
@ -517,8 +517,8 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
|
||||
{"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
|
||||
{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
|
||||
{"WIND", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, 0.0f, 40, "Drag tool", ST_NONE, ST_NONE, NULL},
|
||||
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description
|
||||
{"WIND", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, 0.0f, 40, "Drag tool", ST_NONE, ST_NONE, NULL},
|
||||
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Weights Section H Ins Description
|
||||
};
|
||||
|
||||
// temporarily define abbreviations for impossible p/t values
|
||||
@ -680,7 +680,7 @@ static part_transition ptransitions[PT_NUM] =
|
||||
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
/* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
/* WIND */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
/* WIND */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
|
||||
};
|
||||
#undef IPL
|
||||
#undef IPH
|
||||
|
2
includes/pyconsole.h
Normal file
2
includes/pyconsole.h
Normal file
File diff suppressed because one or more lines are too long
@ -16,6 +16,10 @@ int update_GLOW(UPDATE_FUNC_ARGS) {
|
||||
parts[r>>8].life = 10;
|
||||
}
|
||||
}
|
||||
parts[i].ctype = pv[y/CELL][x/CELL]*16;
|
||||
|
||||
parts[i].tmp = abs((int)((vx[y/CELL][x/CELL]+vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f));
|
||||
//printf("%f %f\n", parts[i].vx, parts[i].vy);
|
||||
if (parts[i].type==PT_NONE) {
|
||||
kill_part(i);
|
||||
return 1;
|
||||
|
@ -120,7 +120,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_NSCN && rt==PT_PSCN)
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_ETRD && (parts[i].life!=5||!(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)))
|
||||
if (ct==PT_ETRD && !(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN))
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0;
|
||||
if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR))
|
||||
@ -137,15 +137,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
||||
conduct_sprk = 0;
|
||||
|
||||
if (conduct_sprk) {
|
||||
if (ct==PT_ETRD) {
|
||||
part_change_type(i,x,y,PT_ETRD);
|
||||
parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 20;
|
||||
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
|
||||
parts[r>>8].life = 4;
|
||||
parts[r>>8].ctype = rt;
|
||||
}
|
||||
else if (rt==PT_WATR||rt==PT_SLTW) {
|
||||
if (rt==PT_WATR||rt==PT_SLTW) {
|
||||
if (parts[r>>8].life==0 && (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)))
|
||||
{
|
||||
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
|
||||
@ -167,6 +159,15 @@ int update_SPRK(UPDATE_FUNC_ARGS) {
|
||||
if (parts[r>>8].temp+10.0f<673.0f&&!legacy_enable&&(rt==PT_METL||rt==PT_BMTL||rt==PT_BRMT||rt==PT_PSCN||rt==PT_NSCN||rt==PT_ETRD||rt==PT_NBLE||rt==PT_IRON))
|
||||
parts[r>>8].temp = parts[r>>8].temp+10.0f;
|
||||
}
|
||||
else if (ct==PT_ETRD && parts[i].life==5)
|
||||
{
|
||||
part_change_type(i,x,y,ct);
|
||||
parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 20;
|
||||
parts[r>>8].life = 4;
|
||||
parts[r>>8].ctype = rt;
|
||||
part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -2370,15 +2370,15 @@ void draw_parts(pixel *vid)
|
||||
}
|
||||
else if (t==PT_GLOW)
|
||||
{
|
||||
fg = 0;
|
||||
fb = 0;
|
||||
fr = 0;
|
||||
if (pv[ny/CELL][nx/CELL]>0) {
|
||||
fg = 6 * pv[ny/CELL][nx/CELL];
|
||||
fb = 4 * pv[ny/CELL][nx/CELL];
|
||||
fr = 2 * pv[ny/CELL][nx/CELL];
|
||||
}
|
||||
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255));
|
||||
fr = restrict_flt(parts[i].temp-(275.13f+32.0f), 0, 128)/50.0f;
|
||||
fg = restrict_flt(parts[i].ctype, 0, 128)/50.0f;
|
||||
fb = restrict_flt(parts[i].tmp, 0, 128)/50.0f;
|
||||
|
||||
cr = restrict_flt(64.0f+parts[i].temp-(275.13f+32.0f), 0, 255);
|
||||
cg = restrict_flt(64.0f+parts[i].ctype, 0, 255);
|
||||
cb = restrict_flt(64.0f+parts[i].tmp, 0, 255);
|
||||
|
||||
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(cr, cg, cb);
|
||||
if (cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
|
||||
{
|
||||
x = nx/CELL;
|
||||
@ -2394,19 +2394,15 @@ void draw_parts(pixel *vid)
|
||||
fire_r[y][x] = fr;
|
||||
}
|
||||
if (cmode == CM_BLOB) {
|
||||
uint8 R = (int)restrict_flt(0x44 + fr*8, 0, 255);
|
||||
uint8 G = (int)restrict_flt(0x88 + fg*8, 0, 255);
|
||||
uint8 B = (int)restrict_flt(0x44 + fb*8, 0, 255);
|
||||
blendpixel(vid, nx+1, ny, cr, cg, cb, 223);
|
||||
blendpixel(vid, nx-1, ny, cr, cg, cb, 223);
|
||||
blendpixel(vid, nx, ny+1, cr, cg, cb, 223);
|
||||
blendpixel(vid, nx, ny-1, cr, cg, cb, 223);
|
||||
|
||||
blendpixel(vid, nx+1, ny, R, G, B, 223);
|
||||
blendpixel(vid, nx-1, ny, R, G, B, 223);
|
||||
blendpixel(vid, nx, ny+1, R, G, B, 223);
|
||||
blendpixel(vid, nx, ny-1, R, G, B, 223);
|
||||
|
||||
blendpixel(vid, nx+1, ny-1, R, G, B, 112);
|
||||
blendpixel(vid, nx-1, ny-1, R, G, B, 112);
|
||||
blendpixel(vid, nx+1, ny+1, R, G, B, 112);
|
||||
blendpixel(vid, nx-1, ny+1, R, G, B, 112);
|
||||
blendpixel(vid, nx+1, ny-1, cr, cg, cb, 112);
|
||||
blendpixel(vid, nx-1, ny-1, cr, cg, cb, 112);
|
||||
blendpixel(vid, nx+1, ny+1, cr, cg, cb, 112);
|
||||
blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112);
|
||||
}
|
||||
}
|
||||
else if (t==PT_LCRY)
|
||||
|
@ -2549,7 +2549,8 @@ int search_ui(pixel *vid_buf)
|
||||
memset(v_buf, 0, ((YRES+MENUSIZE)*(XRES+BARSIZE))*PIXELSIZE);
|
||||
}
|
||||
is_p1 = (exp_res < GRID_X*GRID_Y);
|
||||
free(results);
|
||||
if (results)
|
||||
free(results);
|
||||
active = 0;
|
||||
}
|
||||
|
||||
@ -2824,6 +2825,10 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
||||
data = http_async_req_stop(http, &status, &data_size);
|
||||
if (status == 200)
|
||||
{
|
||||
if (!data||!data_size) {
|
||||
error_ui(vid_buf, 0, "Save data is empty (may be corrupt)");
|
||||
break;
|
||||
}
|
||||
pixel *full_save = prerender_save(data, data_size, &imgw, &imgh);
|
||||
if (full_save!=NULL) {
|
||||
save_pic = rescale_img(full_save, imgw, imgh, &thumb_w, &thumb_h, 2);
|
||||
@ -2842,15 +2847,16 @@ int open_ui(pixel *vid_buf, char *save_id, char *save_date)
|
||||
{
|
||||
http_last_use_2 = time(NULL);
|
||||
info_data = http_async_req_stop(http_2, &status_2, NULL);
|
||||
if (status_2 == 200)
|
||||
if (status_2 == 200 || !info_data)
|
||||
{
|
||||
info_ready = info_parse(info_data, info);
|
||||
if (info_ready==-1) {
|
||||
error_ui(vid_buf, 0, "Not found");
|
||||
if (info_ready<=0) {
|
||||
error_ui(vid_buf, 0, "Save info not found");
|
||||
break;
|
||||
}
|
||||
}
|
||||
free(info_data);
|
||||
if (info_data)
|
||||
free(info_data);
|
||||
active_2 = 0;
|
||||
free(http_2);
|
||||
http_2 = NULL;
|
||||
@ -3546,7 +3552,7 @@ int execute_tagop(pixel *vid_buf, char *op, char *tag)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (result[2])
|
||||
if (result && result[2])
|
||||
{
|
||||
strncpy(svf_tags, result+3, 255);
|
||||
svf_id[15] = 0;
|
||||
@ -3604,14 +3610,16 @@ void execute_save(pixel *vid_buf)
|
||||
free(result);
|
||||
return;
|
||||
}
|
||||
if (result && strncmp(result, "OK", 2))
|
||||
if (!result || strncmp(result, "OK", 2))
|
||||
{
|
||||
if (!result)
|
||||
result = mystrdup("Could not save - no reply from server");
|
||||
error_ui(vid_buf, 0, result);
|
||||
free(result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result[2])
|
||||
if (result && result[2])
|
||||
{
|
||||
strncpy(svf_id, result+3, 15);
|
||||
svf_id[15] = 0;
|
||||
@ -3839,13 +3847,15 @@ struct command_history {
|
||||
};
|
||||
typedef struct command_history command_history;
|
||||
command_history *last_command = NULL;
|
||||
char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show previous commands
|
||||
command_history *last_command2 = NULL;
|
||||
char *console_ui(pixel *vid_buf,char error[255],char console_more) {
|
||||
int mx,my,b,cc,ci = -1;
|
||||
pixel *old_buf=calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE);
|
||||
command_history *currentcommand;
|
||||
command_history *currentcommand2;
|
||||
ui_edit ed;
|
||||
ed.x = 15;
|
||||
ed.y = 210;
|
||||
ed.y = 207;
|
||||
ed.w = XRES;
|
||||
ed.nx = 1;
|
||||
ed.def = "";
|
||||
@ -3854,9 +3864,22 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
||||
ed.hide = 0;
|
||||
ed.multiline = 0;
|
||||
ed.cursor = 0;
|
||||
//fillrect(vid_buf, -1, -1, XRES, 220, 0, 0, 0, 190);
|
||||
memcpy(old_buf,vid_buf,(XRES+BARSIZE)*YRES*PIXELSIZE);
|
||||
fillrect(old_buf, -1, -1, XRES, 220, 0, 0, 0, 190);
|
||||
|
||||
fillrect(old_buf, -1, -1, XRES+1, 220, 0, 0, 0, 190);
|
||||
|
||||
currentcommand2 = malloc(sizeof(command_history));
|
||||
memset(currentcommand2, 0, sizeof(command_history));
|
||||
currentcommand2->prev_command = last_command2;
|
||||
currentcommand2->command = mystrdup(error);
|
||||
last_command2 = currentcommand2;
|
||||
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
cc = 0;
|
||||
while(cc < 80){
|
||||
fillrect(old_buf, -1, -1+cc, XRES+BARSIZE, 2, 0, 0, 0, 160-(cc*2));
|
||||
cc++;
|
||||
}
|
||||
while (!sdl_poll())
|
||||
{
|
||||
b = SDL_GetMouseState(&mx, &my);
|
||||
@ -3866,11 +3889,10 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
||||
|
||||
//clearrect(vid_buf, 0, 0, XRES+BARSIZE, 220);//anyway to make it transparent?
|
||||
memcpy(vid_buf,old_buf,(XRES+BARSIZE)*YRES*PIXELSIZE);
|
||||
draw_line(vid_buf, 1, 219, XRES, 219, 228, 228, 228, XRES+BARSIZE);
|
||||
drawtext(vid_buf, 100, 15, "Welcome to The Powder Toy console v.3 (by cracker64)\n"
|
||||
"Current commands are quit, set, reset, load, create, file, kill, sound\n" //TODO: help command
|
||||
,255, 187, 187, 255);
|
||||
|
||||
draw_line(vid_buf, 0, 219, XRES+BARSIZE-1, 219, 228, 228, 228, XRES+BARSIZE);
|
||||
drawtext(vid_buf, 15, 15, "Welcome to The Powder Toy console v.3 (by cracker64, python by Doxin)" //TODO: help command
|
||||
,255, 255, 255, 255);
|
||||
|
||||
cc = 0;
|
||||
currentcommand = last_command;
|
||||
while(cc < 10)
|
||||
@ -3893,9 +3915,36 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
||||
break;
|
||||
}
|
||||
}
|
||||
cc = 0;
|
||||
currentcommand2 = last_command2;
|
||||
while(cc < 10)
|
||||
{
|
||||
if(currentcommand2==NULL)
|
||||
break;
|
||||
drawtext(vid_buf, 215, 175-(cc*12), currentcommand2->command, 255, 225, 225, 255);
|
||||
if(currentcommand2->prev_command!=NULL)
|
||||
{
|
||||
if(cc<9) {
|
||||
currentcommand2 = currentcommand2->prev_command;
|
||||
} else if(currentcommand2->prev_command!=NULL) {
|
||||
free(currentcommand2->prev_command);
|
||||
currentcommand2->prev_command = NULL;
|
||||
}
|
||||
cc++;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(error)
|
||||
drawtext(vid_buf, 15, 190, error,255, 187, 187, 255);
|
||||
//if(error && ed.str[0]=='\0')
|
||||
//drawtext(vid_buf, 20, 207, error, 255, 127, 127, 200);
|
||||
if(console_more==0)
|
||||
drawtext(vid_buf, 5, 207, ">", 255, 255, 255, 240);
|
||||
else
|
||||
drawtext(vid_buf, 5, 207, "...", 255, 255, 255, 240);
|
||||
|
||||
ui_edit_draw(vid_buf, &ed);
|
||||
ui_edit_process(mx, my, b, &ed);
|
||||
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
|
||||
@ -3907,12 +3956,14 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
||||
currentcommand->command = mystrdup(ed.str);
|
||||
last_command = currentcommand;
|
||||
free(old_buf);
|
||||
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
return currentcommand->command;
|
||||
}
|
||||
if (sdl_key==SDLK_ESCAPE || sdl_key==SDLK_BACKQUOTE)
|
||||
{
|
||||
console_mode = 0;
|
||||
free(old_buf);
|
||||
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
return NULL;
|
||||
}
|
||||
if(sdl_key==SDLK_UP || sdl_key==SDLK_DOWN)
|
||||
@ -3949,6 +4000,7 @@ char *console_ui(pixel *vid_buf,char error[255]) { //TODO: error messages, show
|
||||
}
|
||||
console_mode = 0;
|
||||
free(old_buf);
|
||||
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
2077
src/main.c
2077
src/main.c
File diff suppressed because it is too large
Load Diff
16
src/powder.c
16
src/powder.c
@ -1575,10 +1575,12 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
}
|
||||
else if (t==PT_LAVA) {
|
||||
if (parts[i].ctype && parts[i].ctype<PT_NUM && parts[i].ctype!=PT_LAVA) {
|
||||
if (ptransitions[parts[i].ctype].tht==PT_LAVA&&pt>=ptransitions[parts[i].ctype].thv) s = 0;
|
||||
else if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0;
|
||||
if (parts[i].ctype==PT_THRM&&pt>=ptransitions[PT_BMTL].thv) s = 0;
|
||||
else if (ptransitions[parts[i].ctype].tht==PT_LAVA) {
|
||||
if (pt>=ptransitions[parts[i].ctype].thv) s = 0;
|
||||
}
|
||||
else if (pt>=973.0f) s = 0; // freezing point for lava with any other (not listed in ptransitions as turning into lava) ctype
|
||||
else {
|
||||
if (s) {
|
||||
t = parts[i].ctype;
|
||||
parts[i].ctype = PT_NONE;
|
||||
if (t==PT_THRM) {
|
||||
@ -1995,7 +1997,9 @@ killed:
|
||||
if (try_move(i, x, y, j, clear_y))
|
||||
{
|
||||
parts[i].x = clear_xf+(j-clear_x);
|
||||
parts[i].y = clear_yf;
|
||||
nx = j;
|
||||
ny = clear_y;
|
||||
s = 1;
|
||||
break;
|
||||
}
|
||||
@ -2007,11 +2011,11 @@ killed:
|
||||
else
|
||||
r = -1;
|
||||
if (s)
|
||||
for (j=clear_y+r; j>=0 && j<YRES && j>=clear_y-rt && j<clear_y+rt; j+=r)
|
||||
for (j=ny+r; j>=0 && j<YRES && j>=ny-rt && j<ny+rt; j+=r)
|
||||
{
|
||||
if (try_move(i, x, y, nx, j))
|
||||
if (try_move(i, nx, ny, nx, j))
|
||||
{
|
||||
parts[i].y = clear_yf+(j-clear_y);
|
||||
parts[i].y += j-ny;
|
||||
break;
|
||||
}
|
||||
if ((pmap[j][nx]&255)!=t || (bmap[j/CELL][nx/CELL] && bmap[j/CELL][nx/CELL]!=WL_STREAM))
|
||||
|
116
src/python/tpt_console.py
Normal file
116
src/python/tpt_console.py
Normal file
@ -0,0 +1,116 @@
|
||||
import tpt
|
||||
from tpt import *
|
||||
import sys
|
||||
import code
|
||||
import ctypes
|
||||
import traceback
|
||||
DEBUG=False
|
||||
|
||||
#print "console module loaded."
|
||||
#redirect stdout like this:
|
||||
class logger:
|
||||
def write(self,txt):
|
||||
txt=txt.strip().split("\n")[-1]
|
||||
repr(txt)
|
||||
tpt.log(txt)
|
||||
if(DEBUG==False):
|
||||
sys.stdout=logger()
|
||||
sys.stderr=logger()
|
||||
|
||||
|
||||
element={"none":0,"dust":1,"watr":2,"oil":3,"fire":4,"stne":5,"lava":6,"gunp":7,
|
||||
"nitr":8,"clne":9,"gas":10,"plex":11,"goo":12,"icei":13,"metl":14,"sprk":15,
|
||||
"snow":16,"wood":17,"neut":18,"plut":19,"plnt":20,"acid":21,"void":22,
|
||||
"wtrv":23,"cnct":24,"dstw":25,"salt":26,"sltw":27,"dmnd":28,"bmtl":29,
|
||||
"brmt":30,"phot":31,"uran":32,"wax":33,"mwax":34,"pscn":35,"nscn":36,
|
||||
"lntg":37,"insl":38,"bhol":39,"whol":40,"rbdm":41,"lrbd":42,"ntct":43,
|
||||
"sand":44,"glas":45,"ptct":46,"bgla":47,"thdr":48,"plsm":49,"etrd":50,
|
||||
"nice":51,"nble":52,"btry":53,"lcry":54,"stkm":55,"swch":56,"smke":57,
|
||||
"desl":58,"coal":59,"lo2":60,"o2":61,"inwr":62,"yest":63,"dyst":64,
|
||||
"thrm":65,"glow":66,"brck":67,"hflm":68,"firw":69,"fuse":70,"fsep":71,
|
||||
"amtr":72,"bcol":73,"pcln":74,"hswc":75,"iron":76,"mort":77,"gol":78,
|
||||
"hlif":79,"asim":80,"2x2":81,"dani":82,"amoe":83,"move":84,"pgol":85,
|
||||
"dmoe":86,"34":87,"llif":88,"stan":89,"spng":90,"rime":91,"fog":92,
|
||||
"bcln":93,"love":94,"deut":95,"warp":96,"pump":97,"fwrk":98,"pipe":99,
|
||||
"frzz":100,"frzw":101,"grav":102,"bizr":103,"bizrg":104,"bizrs":105,
|
||||
"inst":106,"isoz":107,"iszs":108,"prti":109,"prto":110,"pste":111,
|
||||
"psts":112,"anar":113,"vine":114,"invis":115,"equalvel":116,"spawn2":117,
|
||||
"spawn":118,"shld1":119,"shld2":120,"shld3":121,"shld4":122,"lolz":123,
|
||||
"wifi":124,"filt":125,"aray":126,"bray":127,"stkm2":128,"bomb":129,
|
||||
"c5":130,"sing":131,"qrtz":132,"pqrt":133,"seed":134,"maze":135,
|
||||
"coag":136,"wall":137,"gnar":138,"repl":139,"myst":140,"boyl":141,
|
||||
"lote":142,"frg2":143,"star":144,"frog":145,"bran":146,"wind":147,
|
||||
"num":148}
|
||||
|
||||
|
||||
def fork_unblock():
|
||||
pass#i need to implement this some day.
|
||||
def error(ex):
|
||||
traceback.print_exc()
|
||||
err=traceback.format_exc()
|
||||
sys.stdout.write(err)
|
||||
|
||||
def clean():
|
||||
#add any functions that must be reachable here.
|
||||
"""copy=["__builtins__","__name__","__doc__","__package__",'tpt','clean',
|
||||
'element','fork','_fork','fork_status','fork_unblock','sys']
|
||||
handle.glob={}
|
||||
for item in copy:
|
||||
handle.glob[item]=globals()[item]"""
|
||||
handle.glob=globals()
|
||||
handle.buf=""
|
||||
|
||||
def handle(txt):
|
||||
try:
|
||||
a=handle.glob
|
||||
except:
|
||||
clean()
|
||||
try:
|
||||
_handle(txt)
|
||||
except Exception as ex:
|
||||
error(ex)
|
||||
|
||||
def _handle(txt):
|
||||
#print "handling '%s'"%txt
|
||||
try:
|
||||
sys.stdout.write(repr(eval(txt,handle.glob)))
|
||||
except:
|
||||
try:
|
||||
exec txt in handle.glob
|
||||
except Exception as ex:
|
||||
error(ex)
|
||||
|
||||
|
||||
_extensions=[]
|
||||
def loadext(fname):
|
||||
ext=__import__(fname)
|
||||
ext.init()
|
||||
_extensions.append(ext)
|
||||
|
||||
def keypress(key):
|
||||
unload=[]
|
||||
for item in _extensions:
|
||||
try:
|
||||
item.key(key)
|
||||
except Exception as ex:
|
||||
error(ex)
|
||||
unload.append(item)
|
||||
for item in unload:
|
||||
item.exit()
|
||||
_extensions.remove(item)
|
||||
|
||||
|
||||
def step():
|
||||
unload=[]
|
||||
for item in _extensions:
|
||||
try:
|
||||
item.step()
|
||||
except Exception as ex:
|
||||
error(ex)
|
||||
unload.append(item)
|
||||
for item in unload:
|
||||
try:
|
||||
item.exit()
|
||||
except Exception as ex:
|
||||
error(ex)
|
||||
_extensions.remove(item)
|
Reference in New Issue
Block a user