Giter Club home page Giter Club logo

smcppsdk's People

Contributors

laper32 avatar moemod avatar

Watchers

 avatar  avatar

Forkers

laper32

smcppsdk's Issues

sourcemod_timers maybe not always Pl_Stop?

problem when using TIMER_REPEAT (sourcemod_timers.h)

ResultType OnTimer(ITimer *pTimer, void *pData) override
{
    detail::CallTimerFunc(m_fn, *this);
    return Pl_Stop;
}

change into ->

ResultType OnTimer(ITimer *pTimer, void *pData) override
{
    return detail::CallTimerFunc(m_fn, *this);
}

(or other better way, i dont know)

m_szArmsModel crashes

Here is the summary about why m_szArmsModel crashes.

First of all, the GetEntProp, with Prop_Send, the function is:

template<class T = cell_t>
T &EntProp(AutoEntity<CBaseEntity*> pEntity, decltype(Prop_Send), const char *prop, int size = sizeof(T), int element=0) {
	assert(pEntity != nullptr);
	sm_sendprop_info_t info = {};
	IServerNetworkable* pNet = ((IServerUnknown*)pEntity)->GetNetworkable();
	if (!pNet) throw std::runtime_error("Edict is not networkable");
	if (!gamehelpers->FindSendPropInfo(pNet->GetServerClass()->GetName(), prop, &info)) throw std::runtime_error(std::string() + "Prop not found: " + prop);
	SendProp* pProp = info.prop;
	ptrdiff_t offset = info.actual_offset;
	T* data = (T*)(reinterpret_cast<intptr_t>(static_cast<CBaseEntity*>(pEntity)) + offset);
	return *data;
}

template<class T = cell_t>
const T &GetEntProp(AutoEntity<CBaseEntity*> pEntity, decltype(Prop_Send), const char *prop, int size=sizeof(T), int element=0) {
	return EntProp<T>(pEntity, Prop_Send, prop, size, element);
}

Now we want to retrieve m_szArmsModel, that we will write it as:

static cell_t GetArm(IPluginContext* pContext, const cell_t* params) {
	CBasePlayer* player = sm::ent_cast<CBasePlayer*>(params[1]);
	if (!player)
	{
		pContext->ReportError("Player is nullptr. Index: %d", params[1]);
		return 0;
	}
	const char* name = sm::GetEntProp<const char*>(player, sm::Prop_Send, "m_szArmsModel");
	return pContext->StringToLocalUTF8(params[2], params[3], name, nullptr);
}

But this will crash.
Be comparing with smn_entities.cpp, we can find that it has several extra steps to retrieve the true result.

if (info.prop->GetProxyFn())
{
	DVariant var;
	info.prop->GetProxyFn()(info.prop, pEntity, (const void *) ((intptr_t) pEntity + offset), &var, element, params[1]);
	src = var.m_pString;
}
else
{
	src = *(char **) ((uint8_t *) pEntity + offset);
}

Now we add up these steps, it works correctly. 79

But the strange thing is that: Get crashes, but set works.
Further investigation is required.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.