Exemplo n.º 1
0
static PyObject *sendEditMap(PyObject *self, PyObject *args)
{
	int cn;
	uchar *data;
	int len;
	server::clientinfo *ci;
	if(!PyArg_ParseTuple(args, "is#", &cn, &data, &len))
		return 0;
	ci = server::getinfo(cn);
	if(!ci)
	{
		PyErr_SetString(PyExc_ValueError, "Invalid cn specified");
		return 0;
	}
	if(ci->state.aitype != AI_NONE)
	{
		PyErr_SetString(PyExc_ValueError, "Cannot send map to AI client");
		return 0;
	}

	//uchar *data;

	//memcpy (data,cdata,len);

	//char *tempfilename;
	defformatstring(tempfilename)("sendmap_%d", lastmillis);

	stream *datafile = opentempfile(tempfilename, "w+b");
    if(!datafile) { sendf(cn, 1, "ris", N_SERVMSG, "failed to open temporary file when preparing to send"); return Py_None; }
    datafile->write(data, len);

	sendfile(cn, 2, datafile, "ri", N_SENDMAP);

	if(datafile) DELETEP(datafile);
	return Py_None;
}
Exemplo n.º 2
0
static PyObject *getMapDataFile(PyObject *self, PyObject *args)
{
	if(!server::mapdata)
		server::mapdata = opentempfile("mapdata", "w+b");
	return PyFile_FromFile(((filestream *) server::mapdata)->file,"mapdata","w+b",NULL);
}