diff --git a/Makefile b/Makefile index 4a77ce051..399f6d622 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ PY_INCPATH := $(shell $(PY_BIN) -c "import os.path,sys;print os.path.join(sys.ex PY_LDFLAGS := $(shell $(PY_BIN) -c "import distutils.sysconfig;print distutils.sysconfig.get_config_var('LINKFORSHARED')") PYCOMMAND := $(PY_BIN) getheader.py -CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -DGRAVFFT -Iincludes/ +CFLAGS := -w -std=c99 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -DGRAVFFT -Iincludes/ -D_GNU_SOURCE OFLAGS := -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations LFLAGS := -lpthread -lSDL -lfftw3f -lm -lbz2 -lX11 -llua5.1 #-lpython$(PY_VERSION) -L$(PY_LIBPATH) -I$(PY_INCPATH) $(PY_LDFLAGS) LFLAGS_X := -lm -lbz2 -lSDLmain -I/Library/Frameworks/Python.framework/Versions/$(PY_VERSION)/include/python$(PY_VERSION) diff --git a/includes/luaconsole.h b/includes/luaconsole.h index 036327ae7..3548dff65 100644 --- a/includes/luaconsole.h +++ b/includes/luaconsole.h @@ -67,4 +67,5 @@ int luatpt_heat(lua_State* l); int luatpt_setfire(lua_State* l); int luatpt_setdebug(lua_State* l); int luatpt_setfpscap(lua_State* l); +int luatpt_getscriptid(lua_State* l); #endif diff --git a/src/interface.c b/src/interface.c index 5679a5fee..de226f3de 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1191,7 +1191,6 @@ void login_ui(pixel *vid_buf) strcpy(svf_user, ed1.str); md5_ascii(svf_pass, (unsigned char *)ed2.str, 0); - res = http_multipart_post( "http://" SERVER "/Login.api", NULL, NULL, NULL, diff --git a/src/luaconsole.c b/src/luaconsole.c index 186764d3e..c56c1a3d9 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -2,6 +2,11 @@ #include #include #include +#include +#include +#include +#include +#include lua_State *l; int step_functions[6] = {0, 0, 0, 0, 0, 0}; @@ -56,6 +61,7 @@ void luacon_open(){ {"setfire", &luatpt_setfire}, {"setdebug", &luatpt_setdebug}, {"setfpscap",&luatpt_setfpscap}, + {"getscriptid",&luatpt_getscriptid}, {NULL,NULL} }; @@ -1062,4 +1068,77 @@ int fpscap = luaL_optint(l, 1, 0); limitFPS = fpscap; return 0; } +int luatpt_getscriptid(lua_State* l) +{ + + int sock, port, numrec; + struct sockaddr_in serv_addr; + struct hostent *server; + char * id; + char * filedatabuffer[1024]; + id = mystrdup(luaL_optstring(l, 1, "1")); + for (int i = 0; i < strlen(id);i++) + if(id[i]>57||id[i]<48){ + luaL_error(l, "Invalid ID format."); + return 0; + } + + port = 10457; + sock = socket(AF_INET, SOCK_STREAM, 0); + + server = gethostbyname(SERVER); + //server = gethostbyname("localhost"); + if (server == NULL) { + luaL_error(l, "Error fetching host IP."); + return 0; + } + + bzero((char *) &serv_addr, sizeof(serv_addr)); + + serv_addr.sin_family = AF_INET; + bcopy((char *)server->h_addr, + (char *)&serv_addr.sin_addr.s_addr, + server->h_length); + serv_addr.sin_port = htons(port); + + if (connect(sock,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0) { + luaL_error(l, "Error connecting to host."); + return 0; + } + + + + char newid[80]; + char file[80]; + strcpy(file,id); + strcat(file,".lua"); + FILE *filetowriteto; + filetowriteto=fopen(file, "w"); + strcpy(newid,id); + strcat(newid,"\n"); + write(sock,newid,strlen(newid)); + while(1){ + bzero(filedatabuffer,1024); + numrec = read(sock,filedatabuffer,1024); + if(numrec<0){ + luaL_error(l, "Transfer Error"); + return 0; + } + fputs(filedatabuffer,filetowriteto); + if(numrec<=1) + { + break; + } + if(numrec<1024) + break; + + } +fclose(filetowriteto); +char tempstr[120]; +strcpy(tempstr,"dofile(\""); +strcat(tempstr,file); +strcat(tempstr,"\")"); +luacon_eval(tempstr); +return 0; +} #endif