summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLieuwe <lieuwemo@gmail.com>2011-03-06 14:39:50 (GMT)
committer Lieuwe <lieuwemo@gmail.com>2011-03-06 14:39:50 (GMT)
commitf599959efed6cb87d25382f54c6657094603dcc5 (patch)
treedb7a736c96a907178d9eaccc5b1255a33ea3efc8 /src
parentd619204d589281b824c8e689ad35429a56a9cd47 (diff)
downloadpowder-f599959efed6cb87d25382f54c6657094603dcc5.zip
powder-f599959efed6cb87d25382f54c6657094603dcc5.tar.gz
more work on the chat client, it now supports nick changes
Diffstat (limited to 'src')
-rw-r--r--src/main.c18
-rw-r--r--src/python/tpt_console.py35
2 files changed, 38 insertions, 15 deletions
diff --git a/src/main.c b/src/main.c
index 0187aa2..35ebc6b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1838,6 +1838,17 @@ emb_get_mouse(PyObject *self, PyObject *args)
return Py_BuildValue("(ii(iii))",x,y,b1,b2,b3);
}
+//svf_name
+emb_get_name(PyObject *self, PyObject *args)
+{
+ if(!PyArg_ParseTuple(args, ":get_name"))
+ return NULL;
+ if(svf_login)
+ return Py_BuildValue("s",svf_user);
+ else
+ return Py_BuildValue("s","");
+}
+
static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your function here!
{"create", emb_create, METH_VARARGS|METH_KEYWORDS, "create a particle."},
{"log", emb_log, METH_VARARGS, "logs an error string to the console."},
@@ -1869,6 +1880,7 @@ static PyMethodDef EmbMethods[] = { //WARNING! don't forget to register your fun
{"draw_fillrect", emb_draw_fillrect, METH_VARARGS, "draw a rect."},
{"get_width", emb_get_width, METH_VARARGS, "get string width."},
{"get_mouse", emb_get_mouse, METH_VARARGS, "get mouse status."},
+ {"get_name", emb_get_name, METH_VARARGS, "get name of logged in user"},
{NULL, NULL, 0, NULL}
};
@@ -3546,12 +3558,6 @@ int main(int argc, char *argv[])
}
SDL_CloseAudio();
http_done();
- //make sure no threads are blocking us
- //fork_unblock
- pargs=Py_BuildValue("(s)","fork_unblock()");//this deamonises all threads.
- pvalue = PyObject_CallObject(pfunc, pargs);
- Py_DECREF(pargs);
- pargs=NULL;
Py_Finalize();//cleanup any python stuff.
return 0;
}
diff --git a/src/python/tpt_console.py b/src/python/tpt_console.py
index 620307b..491faf5 100644
--- a/src/python/tpt_console.py
+++ b/src/python/tpt_console.py
@@ -42,6 +42,7 @@ element={"none":0,"dust":1,"watr":2,"oil":3,"fire":4,"stne":5,"lava":6,"gunp":7,
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)
@@ -78,18 +79,34 @@ def _handle(txt):
_extensions=[]
def loadext(fname):
- _extensions.append(__import__(fname))
+ ext=__import__(fname)
+ ext.init()
+ _extensions.append(ext)
def keypress(key):
- try:
- for item in _extensions:
+ unload=[]
+ for item in _extensions:
+ try:
item.key(key)
- except Exception as ex:
- error(ex)
+ except Exception as ex:
+ error(ex)
+ unload.append(item)
+ for item in unload:
+ item.exit()
+ _extensions.remove(item)
+
def step():
- try:
- for item in _extensions:
+ unload=[]
+ for item in _extensions:
+ try:
item.step()
- except Exception as ex:
- error(ex)
+ 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)