//getentityfieldstring returns data as would be written to a savegame, eg... "0.05" (float), "0 0 1" (vector), or "Hello World!" (string). Function names can also be returned.
//putentityfieldstring puts the data returned by getentityfieldstring back into the entity.
+//IRC
+void irc_connect() = #550;
+void irc_disconnect() = #551;
+void irc_write(string line) = #552;
+
// assorted undocumented extensions
string(string, float) netaddress_resolve = #625;
string(string search, string replace, string subject) strreplace = #484;
// values at level start
// for coop respawn
+//IRC
+void irc_connect() = #550;
+void irc_disconnect() = #551;
+void irc_write(string line) = #552;
+
//============================================================================
static qboolean irc_registered;
static qboolean irc_connected;
+static cvar_t irc_server = { CVAR_SAVE, "irc_server", "", "the address of the IRC server to connect to." };
static cvar_t irc_nickname = { CVAR_SAVE, "irc_nickname", "darkplaces", "nickname to use when connecting to IRC" };
static cvar_t irc_username = { CVAR_SAVE, "irc_username", "darkplaces", "username/ident to use when connecting to IRC" };
static cvar_t irc_realname = { CVAR_SAVE, "irc_realname", "darkplaces", "realname to use when connecting to IRC" };
static mempool_t *irc_mempool;
-
-static void IRC_Disconnect(void)
+void IRC_Disconnect(void)
{
if (irc_socket)
{
irc_connected = false;
}
-static int IRC_Connect(const char *addr)
+int IRC_Connect(void)
{
lhnetaddress_t address;
lhnetaddress_t peeraddress;
return 0;
}
- if (!LHNETADDRESS_FromString(&peeraddress, addr, 6667))
+ if (!LHNETADDRESS_FromString(&peeraddress, irc_server.string, 6667))
{
- Con_Printf("[IRC] Bad server address: %s.\n", addr);
+ Con_Printf("[IRC] Bad server address: %s.\n", irc_server.string);
return 0;
}
return 0;
}
- Con_Printf("[IRC] Connecting to %s...\n", addr);
+ Con_Printf("[IRC] Connecting to %s...\n", irc_server.string);
irc_connected = true;
return 1;
}
-static void IRC_AddMessage(const char *message)
+void IRC_AddMessage(const char *message)
{
size_t len = strlen(message);
static void IRC_ProcessMessage(const char *line)
{
ircmessage_t *msg;
+ prvm_prog_t *prog;
if ((msg = IRC_ParseMessage(line)))
{
IRC_AddMessage(va(vabuf, sizeof(vabuf), "PONG :%s", msg->args[0]));
}
- IRC_DumpMessage(msg);
+ //IRC_DumpMessage(msg);
IRC_FreeMessage(msg);
}
+
+ prog = SVVM_prog;
+ if (PRVM_serverfunction(IRC_Parse))
+ {
+ int restorevm_tempstringsbuf_cursize;
+ restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
+ PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, line);
+ PRVM_serverglobalfloat(time) = sv.time;
+ PRVM_serverglobaledict(self) = PRVM_EDICT_TO_PROG(host_client->edict);
+ prog->ExecuteProgram(prog, PRVM_serverfunction(IRC_Parse), "QC function IRC_Parse is missing");
+ prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
+ }
}
static void IRC_ProcessAllMessages(void)
static void IRC_Connect_f(void)
{
- if (Cmd_Argc() != 2)
- {
- Con_Print("ircconnect <address> : connect to an IRC server\n");
- return;
- }
-
- if (IRC_Connect(Cmd_Argv(1)))
+ if (IRC_Connect())
IRC_Register();
}
IRC_Disconnect();
}
-static void IRC_IRC_f(void)
+static void IRC_Write_f(void)
{
if (Cmd_Argc() < 2)
{
{
irc_mempool = Mem_AllocPool("IRC", 0, NULL);
+ Cvar_RegisterVariable(&irc_server);
Cvar_RegisterVariable(&irc_nickname);
Cvar_RegisterVariable(&irc_username);
Cvar_RegisterVariable(&irc_realname);
Cmd_AddCommand("ircconnect", IRC_Connect_f, "connect to an IRC server");
Cmd_AddCommand("ircdisconnect", IRC_Disconnect_f, "disconnect from an IRC server");
- Cmd_AddCommand("irc", IRC_IRC_f, "send raw messages to a connected IRC server");
+ Cmd_AddCommand("irc", IRC_Write_f, "send raw messages to a connected IRC server");
irc_connected = false;
}
void IRC_Frame(void);
void IRC_Shutdown(void);
+int IRC_Connect(void);
+void IRC_Disconnect(void);
+void IRC_AddMessage(const char* message);
+
#endif
{
SOCKLEN_T namelen;
int bindresult;
+ lhnetaddressnative_t *localaddress;
if (!address)
return 0;
lhnetsocket->address = *address;
- lhnetaddressnative_t *localaddress = (lhnetaddressnative_t *)&lhnetsocket->address;
+ localaddress = (lhnetaddressnative_t *)&lhnetsocket->address;
#ifdef SUPPORTIPV6
if (address->addresstype == LHNETADDRESSTYPE_INET6)
{
{
SOCKLEN_T namelen;
int connectresult;
+ lhnetaddressnative_t *peeraddress;
if (!address)
return 0;
- lhnetaddressnative_t *peeraddress = (lhnetaddressnative_t *)address;
+ peeraddress = (lhnetaddressnative_t *)address;
#ifdef SUPPORTIPV6
if (address->addresstype == LHNETADDRESSTYPE_INET6)
{
lhnetsocket_t *LHNET_OpenSocket(lhnetaddress_t *address, lhnetaddress_t *peeraddress, int use_tcp, int use_blocking, int register_for_select)
{
lhnetsocket_t *lhnetsocket, *s;
+ int addresstype;
if (!address && !peeraddress)
return NULL;
- int addresstype = address ? address->addresstype : peeraddress->addresstype;
+ addresstype = address ? address->addresstype : peeraddress->addresstype;
if (peeraddress && addresstype != peeraddress->addresstype)
{
Con_Printf("Cannot connect different address types.\n");
)
#endif
{
- int bindresult;
-
+
#if defined(SOL_RFC1149) && defined(RFC1149_1149ONLY)
// we got reports of massive lags when this protocol was chosen as transport
// so better turn it off
return -1;
if (lhnetsocket->address.addresstype == LHNETADDRESSTYPE_LOOP)
{
+ lhnetpacket_t *p;
if (!address)
{
Con_DPrintf("LHNET_Write: destination address required on LHNETADDRESSTYPE_LOOP\n", LHNETPRIVATE_StrError());
return -1;
}
- lhnetpacket_t *p;
p = (lhnetpacket_t *)Z_Malloc(sizeof(*p) + contentlength);
p->data = (void *)(p + 1);
memcpy(p->data, content, contentlength);
#include "csprogs.h"
#include "ft2.h"
#include "mdfour.h"
+#include "irc.h"
extern cvar_t prvm_backtraceforwarnings;
#ifdef USEODE
VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
VM_physics_ApplyCmd(ed, &f);
}
+
+
+void VM_irc_connect(prvm_prog_t *prog)
+{
+ IRC_Connect();
+}
+
+void VM_irc_disconnect(prvm_prog_t *prog)
+{
+ IRC_Disconnect();
+}
+
+void VM_irc_write(prvm_prog_t *prog)
+{
+ char string[VM_STRINGTEMP_LENGTH];
+
+ VM_VarString(prog, 0, string, sizeof(string));
+ IRC_AddMessage(string);
+}
\ No newline at end of file
void VM_physics_addforce(prvm_prog_t *prog);
void VM_physics_addtorque(prvm_prog_t *prog);
+// irc
+void VM_irc_connect(prvm_prog_t *prog);
+void VM_irc_disconnect(prvm_prog_t *prog);
+void VM_irc_write(prvm_prog_t *prog);
#endif
PRVM_DECLARE_function(SV_PausedTic)
PRVM_DECLARE_function(SV_PlayerPhysics)
PRVM_DECLARE_function(SV_Shutdown)
+PRVM_DECLARE_function(IRC_Parse)
PRVM_DECLARE_function(SetChangeParms)
PRVM_DECLARE_function(SetNewParms)
PRVM_DECLARE_function(StartFrame)
PRVM_DECLARE_serverfunction(SV_PausedTic)
PRVM_DECLARE_serverfunction(SV_PlayerPhysics)
PRVM_DECLARE_serverfunction(SV_Shutdown)
+PRVM_DECLARE_serverfunction(IRC_Parse)
PRVM_DECLARE_serverfunction(SetChangeParms)
PRVM_DECLARE_serverfunction(SetNewParms)
PRVM_DECLARE_serverfunction(StartFrame)
NULL, // #547
NULL, // #548
NULL, // #549
-NULL, // #550
-NULL, // #551
-NULL, // #552
+VM_irc_connect, // #550
+VM_irc_disconnect, // #551
+VM_irc_write, // #552
NULL, // #553
NULL, // #554
NULL, // #555