extensions/sdktools/vnatives.cpp
changeset 1152 419824987e06
parent 1151 71424ad456bc
child 1153 f561f417eda7
     1.1 --- a/extensions/sdktools/vnatives.cpp	Mon Jul 23 21:01:58 2007 +0000
     1.2 +++ b/extensions/sdktools/vnatives.cpp	Mon Jul 23 21:51:22 2007 +0000
     1.3 @@ -21,6 +21,7 @@
     1.4   * Version: $Id$
     1.5   */
     1.6  
     1.7 +#include <sh_string.h>
     1.8  #include "extension.h"
     1.9  #include "vcallbuilder.h"
    1.10  #include "vnatives.h"
    1.11 @@ -317,6 +318,39 @@
    1.12  	return 1;
    1.13  }
    1.14  
    1.15 +static String *g_lightstyle[MAX_LIGHTSTYLES] = {NULL};
    1.16 +static cell_t SetLightStyle(IPluginContext *pContext, const cell_t *params)
    1.17 +{
    1.18 +	if (!g_lightstyle)
    1.19 +	{
    1.20 +		/* We allocate and never free this because the Engine wants to hold onto it :\
    1.21 +		 * in theory we could hook light style and know whether we're supposed to free 
    1.22 +		 * this or not on shutdown, but for 4K of memory, it doesn't seem worth it yet.
    1.23 +		 * So, it's a :TODO:!
    1.24 +		 */
    1.25 +	}
    1.26 +
    1.27 +	int style = params[1];
    1.28 +	if (style >= MAX_LIGHTSTYLES)
    1.29 +	{
    1.30 +		return pContext->ThrowNativeError("Light style %d is invalid (range: 0-%d)", style, MAX_LIGHTSTYLES - 1);
    1.31 +	}
    1.32 +
    1.33 +	if (g_lightstyle[style] == NULL)
    1.34 +	{
    1.35 +		g_lightstyle[style] = new String();
    1.36 +	}
    1.37 +
    1.38 +	char *str;
    1.39 +	pContext->LocalToString(params[2], &str);
    1.40 +
    1.41 +	g_lightstyle[style]->assign(str);
    1.42 +
    1.43 +	engine->LightStyle(style, str);
    1.44 +
    1.45 +	return 1;
    1.46 +}
    1.47 +
    1.48  sp_nativeinfo_t g_Natives[] = 
    1.49  {
    1.50  	{"ExtinguishPlayer",	ExtinguishPlayer},
    1.51 @@ -330,6 +364,7 @@
    1.52  	{"TeleportPlayer",		TeleportPlayer},
    1.53  	{"TeleportEntity",		TeleportPlayer},
    1.54  	{"SetClientViewEntity",	SetClientViewEntity},
    1.55 +	{"SetLightStyle",		SetLightStyle},
    1.56  	{NULL,					NULL},
    1.57  };
    1.58