Example #1
0
static void *ekg2_dlopen(const char *name) {
#ifdef NO_POSIX_SYSTEM
	void *tmp = LoadLibraryA(name);
#else
	/* RTLD_LAZY is bad flag, because code can SEGV on executing undefined symbols...
	 *	it's better to fail earlier than later with SIGSEGV
	 *
	 * RTLD_GLOBAL is bad flag also, because we have no need to export symbols to another plugns
	 *	we should do it by queries... Yeah, I know it was used for example in perl && irc plugin.
	 *	But we cannot do it. Because if we load irc before sim plugin. Than we'll have unresolved symbols
	 *	even if we load sim plugin later.
	 */
	/*
	 * RTLD_GLOBAL is required by perl and python plugins...
	 *	need investigation. [XXX]
	 */
	void *tmp = dlopen(name, RTLD_NOW | RTLD_GLOBAL);
#endif
	if (!tmp) {
		debug_warn("[plugin] could not be loaded: %s %s\n", name, dlerror());
	} else {
		debug_ok("[plugin] loaded: %s\n", name);
	}
	return tmp;
}
Example #2
0
void OSSemPend (uint8 dev,uint32 timeout,uint8 *perr)
{
	int ret=0;
	struct timespec outtime;
	struct timeval now;

	pthread_mutex_lock(&QueueMutex[dev]);
	gettimeofday(&now,NULL);
	//outtime.tv_sec = time(0)+timeout/1000;
	//outtime.tv_nsec = (timeout%1000)*1000*1000;
	outtime.tv_sec = now.tv_sec+timeout/1000;
	//outtime.tv_nsec = now.tv_usec*1000 + (timeout%1000)*1000*1000;
	outtime.tv_nsec = (timeout%1000)*1000*1000;
	//printf("ossem  timeout  is right!\n ");
	if(timeout == (uint32)NULL)
	{
		pthread_cond_wait(&QueueSems[dev],&QueueMutex[dev]);
	}
	else
	{
		ret=pthread_cond_timedwait(&QueueSems[dev],&QueueMutex[dev],&outtime);
		if(ret != 0) {
			debug_warn(gDebugModule[MSIC_MODULE],"[%s][%s][%d]pthread_cond_timedwait %s\n",FILE_LINE,strerror(ret));
		}
	}
	*perr = (uint8)ret;
	pthread_mutex_unlock(&QueueMutex[dev]);

}
Example #3
0
File: CGUI.cpp Project: 2asoft/0ad
void CGUI::Destroy()
{
	// We can use the map to delete all
	//  now we don't want to cancel all if one Destroy fails
	for (const std::pair<CStr, IGUIObject*>& p : m_pAllObjects)
	{
		try
		{
			p.second->Destroy();
		}
		catch (PSERROR_GUI& e)
		{
			UNUSED2(e);
			debug_warn(L"CGUI::Destroy error");
			// TODO Gee: Handle
		}

		delete p.second;
	}
	m_pAllObjects.clear();

	for (const std::pair<CStr, CGUISprite*>& p : m_Sprites)
		delete p.second;
	m_Sprites.clear();
	m_Icons.clear();
}
Example #4
0
FSEventStreamRef CreateEventStream( DirWatchMap path )
{
  if ( ( g_Stream == NULL ) && CanRunNotifications() )
  {
    CFStringRef* pathLists = (CFStringRef*)malloc( sizeof(CFStringRef*) * path.size() );
    int   index = 0;
    for ( DirWatchMap::iterator it = path.begin() ; it != path.end(); ++it)
    {
      pathLists[index] = CFStringCreateWithFileSystemRepresentation( NULL, OsString(it->path).c_str());
      index++;
    }
    CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)pathLists, index, NULL);

    FSEventStreamContext *callbackInfo = NULL;
 
    FSEventStreamRef stream = FSEventStreamCreate(NULL, &fsevent_callback, callbackInfo, pathsToWatch,
        kFSEventStreamEventIdSinceNow, 1.0, kFSEventStreamCreateFlagFileEvents );

    CFRelease( pathsToWatch );
    free( pathLists );

    FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
    if (!FSEventStreamStart(stream)) 
      debug_warn(L"event_loop FSEventStreamStart failed!"); 
    else
      return stream;
  }
  return NULL;
}
Example #5
0
void CGUI::Destroy()
{
	// We can use the map to delete all
	//  now we don't want to cancel all if one Destroy fails
	for (map_pObjects::iterator it = m_pAllObjects.begin(); it != m_pAllObjects.end(); ++it)
	{
		try
		{
			it->second->Destroy();
		}
		catch (PSERROR_GUI& e)
		{
			UNUSED2(e);
			debug_warn(L"CGUI::Destroy error");
			// TODO Gee: Handle
		}
		
		delete it->second;
	}

	// Clear all
	m_pAllObjects.clear();
	for(std::map<CStr, CGUISprite*>::iterator it = m_Sprites.begin(); it != m_Sprites.end(); ++it)
		delete it->second;
	m_Sprites.clear();
	m_Icons.clear();
}
Example #6
0
File: unix.cpp Project: Marlinc/0ad
Status sys_open_url(const std::string& url)
{
	pid_t pid = fork();
	if (pid < 0)
	{
		debug_warn(L"Fork failed");
		return ERR::FAIL;
	}
	else if (pid == 0)
	{
		// we are the child

		execlp(URL_OPEN_COMMAND, URL_OPEN_COMMAND, url.c_str(), (const char*)NULL);

		debug_printf(L"Failed to run '" URL_OPEN_COMMAND "' command\n");

		// We can't call exit() because that'll try to free resources which were the parent's,
		// so just abort here
		abort();
	}
	else
	{
		// we are the parent

		// TODO: maybe we should wait for the child and make sure it succeeded

		return INFO::OK;
	}
}
Example #7
0
static void* reconn_fun(void* arg){
		conn_t* conn;
		queue_t* q = &g_ctx.reconn_q;
		rval_t rval;
		int  times = 1;
		while(1){
				conn = list_entry(deque(q), conn_t,  reconn_link);
				assert(conn->conn_state == CONNECTING);
				assert(conn->conn_type == ACTIVE);
				debug_info("start reconn conn[%d], fd[%d],%s \n",
						   conn->id, conn->sockfd, dump_addr(conn->addr));
				rval =  re_connect(conn);
				if(success(rval)){
					debug_info("reconn conn[%d], fd[%d] success! \n", conn->id, conn->sockfd);
					set_conn_state(conn, CONNECTED);
					add_event(conn);

				}else{
						debug_warn("reconn conn[%d], fd[%d] failed! errno[%d]\n",
								conn->id, conn->sockfd, rval.err);
						enque(q, &conn->reconn_link); //continue reconn
				}
				sleep(times);
		}
}
Example #8
0
static GLenum ParseAttribSemantics(const CStr& str)
{
    // Map known semantics onto the attribute locations documented by NVIDIA
    if (str == "gl_Vertex") return 0;
    if (str == "gl_Normal") return 2;
    if (str == "gl_Color") return 3;
    if (str == "gl_SecondaryColor") return 4;
    if (str == "gl_FogCoord") return 5;
    if (str == "gl_MultiTexCoord0") return 8;
    if (str == "gl_MultiTexCoord1") return 9;
    if (str == "gl_MultiTexCoord2") return 10;
    if (str == "gl_MultiTexCoord3") return 11;
    if (str == "gl_MultiTexCoord4") return 12;
    if (str == "gl_MultiTexCoord5") return 13;
    if (str == "gl_MultiTexCoord6") return 14;
    if (str == "gl_MultiTexCoord7") return 15;

    // Define some arbitrary names for user-defined attribute locations
    // that won't conflict with any standard semantics
    if (str == "CustomAttribute0") return 1;
    if (str == "CustomAttribute1") return 6;
    if (str == "CustomAttribute2") return 7;

    debug_warn("Invalid attribute semantics");
    return 0;
}
Example #9
0
void IGUIObject::AddSetting(const EGUISettingType& Type, const CStr& Name)
{
	// Is name already taken?
	if (m_Settings.count(Name) >= 1)
		return;

	// Construct, and set type
	m_Settings[Name].m_Type = Type;

	switch (Type)
	{
#define TYPE(type) \
	case GUIST_##type: \
		m_Settings[Name].m_pSetting = new type(); \
		break;

		// Construct the setting.
		#include "GUItypes.h"

#undef TYPE

	default:
		debug_warn(L"IGUIObject::AddSetting failed, type not recognized!");
		break;
	}
}
Example #10
0
CStr CStr::Pad(PS_TRIM_MODE Mode, size_t Length) const
{
	size_t Left = 0, Right = 0;

	if (Length <= length())
		return *this;
	
	// From here: Length-length() >= 1

	switch (Mode)
	{
	case PS_TRIM_LEFT:
		Left = Length - length();
		break;

	case PS_TRIM_RIGHT:
		Right = Length - length();
		break;

	case PS_TRIM_BOTH:
		Left  = (Length - length() + 1)/2;
		Right = (Length - length() - 1)/2; // cannot be negative
		break;

	default:
		debug_warn(L"CStr::Trim: invalid Mode");
	}

	return std::tstring(Left, _T(' ')) + *this + std::tstring(Right, _T(' '));
}
Example #11
0
bool CConfigDB::WriteFile(EConfigNamespace ns, const VfsPath& path)
{
	if (ns < 0 || ns >= CFG_LAST)
	{
		debug_warn(L"CConfigDB: Invalid ns value");
		return false;
	}

	shared_ptr<u8> buf;
	AllocateAligned(buf, 1*MiB, maxSectorSize);
	char* pos = (char*)buf.get();
	TConfigMap &map=m_Map[ns];
	for(TConfigMap::const_iterator it = map.begin(); it != map.end(); ++it)
	{
		pos += sprintf(pos, "%s = \"%s\"\n", it->first.c_str(), it->second[0].m_String.c_str());
	}
	const size_t len = pos - (char*)buf.get();

	Status ret = g_VFS->CreateFile(path, buf, len);
	if(ret < 0)
	{
		LOGERROR(L"CConfigDB::WriteFile(): CreateFile \"%ls\" failed (error: %d)", path.string().c_str(), (int)ret);
		return false;
	}

	return true;
}
Example #12
0
void CSimulation2Impl::ReportSerializationFailure(
	SerializationTestState* primaryStateBefore, SerializationTestState* primaryStateAfter,
	SerializationTestState* secondaryStateBefore, SerializationTestState* secondaryStateAfter)
{
	OsPath path = psLogDir() / "oos_log";
	CreateDirectories(path, 0700);

	// Clean up obsolete files from previous runs
	wunlink(path / "hash.before.a");
	wunlink(path / "hash.before.b");
	wunlink(path / "debug.before.a");
	wunlink(path / "debug.before.b");
	wunlink(path / "state.before.a");
	wunlink(path / "state.before.b");
	wunlink(path / "hash.after.a");
	wunlink(path / "hash.after.b");
	wunlink(path / "debug.after.a");
	wunlink(path / "debug.after.b");
	wunlink(path / "state.after.a");
	wunlink(path / "state.after.b");

	if (primaryStateBefore)
		DumpSerializationTestState(*primaryStateBefore, path, L"before.a");
	if (primaryStateAfter)
		DumpSerializationTestState(*primaryStateAfter, path, L"after.a");
	if (secondaryStateBefore)
		DumpSerializationTestState(*secondaryStateBefore, path, L"before.b");
	if (secondaryStateAfter)
		DumpSerializationTestState(*secondaryStateAfter, path, L"after.b");

	debug_warn(L"Serialization test failure");
}
Example #13
0
static CFixedVector2D NearestPointOnGoal(CFixedVector2D pos, const CCmpPathfinder::Goal& goal)
{
	CFixedVector2D g(goal.x, goal.z);

	switch (goal.type)
	{
	case CCmpPathfinder::Goal::POINT:
	{
		return g;
	}

 	case CCmpPathfinder::Goal::CIRCLE:
	{
		CFixedVector2D d = pos - g;
		if (d.IsZero())
			d = CFixedVector2D(fixed::FromInt(1), fixed::Zero()); // some arbitrary direction
		d.Normalize(goal.hw);
		return g + d;
	}

	case CCmpPathfinder::Goal::SQUARE:
	{
		CFixedVector2D halfSize(goal.hw, goal.hh);
		CFixedVector2D d = pos - g;
		return g + Geometry::NearestPointOnSquare(d, goal.u, goal.v, halfSize);
	}

	default:
		debug_warn(L"invalid type");
		return CFixedVector2D();
	}
}
Example #14
0
void CGUI::Xeromyces_ReadEffects(XMBElement Element, CXeromyces* pFile, SGUIImageEffects &effects)
{
	XMBAttributeList attributes = Element.GetAttributes();
	for (int i=0; i<attributes.Count; ++i)
	{
		XMBAttribute attr = attributes.Item(i);
		CStr attr_name (pFile->GetAttributeString(attr.Name));
		CStrW attr_value (attr.Value.FromUTF8());

		if (attr_name == "add_color")
		{
			CColor color;
			if (!GUI<int>::ParseColor(attr_value, color, 0.f))
				LOGERROR(L"GUI: Error parsing '%hs' (\"%ls\")", attr_name.c_str(), attr_value.c_str());
			else effects.m_AddColor = color;
		}
		else if (attr_name == "grayscale")
		{
			effects.m_Greyscale = true;
		}
		else
		{
			debug_warn(L"Invalid data - DTD shouldn't allow this");
		}
	}
}
Example #15
0
std::vector<std::pair<CStr, CConfigValueSet> > CConfigDB::GetValuesWithPrefix(EConfigNamespace ns, const CStr& prefix)
{
	std::vector<std::pair<CStr, CConfigValueSet> > ret;

	if (ns < 0 || ns >= CFG_LAST)
	{
		debug_warn(L"CConfigDB: Invalid ns value");
		return ret;
	}

	for (TConfigMap::iterator it = m_Map[CFG_COMMAND].begin(); it != m_Map[CFG_COMMAND].end(); ++it)
	{
		if (boost::algorithm::starts_with(it->first, prefix))
			ret.push_back(std::make_pair(it->first, it->second));
	}

	for (int search_ns = ns; search_ns >= 0; search_ns--)
	{
		for (TConfigMap::iterator it = m_Map[search_ns].begin(); it != m_Map[search_ns].end(); ++it)
		{
			if (boost::algorithm::starts_with(it->first, prefix))
				ret.push_back(std::make_pair(it->first, it->second));
		}
	}

	return ret;
}
Example #16
0
JSBool JSI_IGUIObject::getComputedSize(JSContext* cx, uintN argc, jsval* vp)
{
	UNUSED2(argc);

	IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx, vp), &JSI_IGUIObject::JSI_class, NULL);
	if (!e)
		return JS_FALSE;

	e->UpdateCachedSize();
	CRect size = e->m_CachedActualSize;

	JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
	try
	{
		g_ScriptingHost.SetObjectProperty_Double(obj, "left", size.left);
		g_ScriptingHost.SetObjectProperty_Double(obj, "right", size.right);
		g_ScriptingHost.SetObjectProperty_Double(obj, "top", size.top);
		g_ScriptingHost.SetObjectProperty_Double(obj, "bottom", size.bottom);
	}
	catch (PSERROR_Scripting_ConversionFailed)
	{
		debug_warn(L"Error creating size object!");
		return JS_FALSE;
	}

	JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(obj));
	return JS_TRUE;
}
Example #17
0
File: CGUI.cpp Project: 2asoft/0ad
/**
 * @callgraph
 */
void CGUI::LoadXmlFile(const VfsPath& Filename, boost::unordered_set<VfsPath>& Paths)
{
	Paths.insert(Filename);

	CXeromyces XeroFile;
	if (XeroFile.Load(g_VFS, Filename, "gui") != PSRETURN_OK)
		return;

	XMBElement node = XeroFile.GetRoot();

	CStr root_name(XeroFile.GetElementString(node.GetNodeName()));
	try
	{
		if (root_name == "objects")
		{
			Xeromyces_ReadRootObjects(node, &XeroFile, Paths);

			// Re-cache all values so these gets cached too.
			//UpdateResolution();
		}
		else if (root_name == "sprites")
			Xeromyces_ReadRootSprites(node, &XeroFile);
		else if (root_name == "styles")
			Xeromyces_ReadRootStyles(node, &XeroFile);
		else if (root_name == "setup")
			Xeromyces_ReadRootSetup(node, &XeroFile);
		else
			debug_warn(L"CGUI::LoadXmlFile error");
	}
	catch (PSERROR_GUI& e)
	{
		LOGERROR("Errors loading GUI file %s (%u)", Filename.string8(), e.getCode());
		return;
	}
}
Example #18
0
void CModelAbstract::CalcSelectionBox()
{
	if (m_CustomSelectionShape)
	{
		// custom shape
		switch(m_CustomSelectionShape->m_Type)
		{
		case CustomSelectionShape::BOX:
			{
				// create object-space bounds according to the information in the descriptor, and transform them to world-space.
				// the box is centered on the X and Z axes, but extends from 0 to its height on the Y axis.
				const float width = m_CustomSelectionShape->m_Size0;
				const float depth = m_CustomSelectionShape->m_Size1;
				const float height = m_CustomSelectionShape->m_Height;

				CBoundingBoxAligned bounds;
				bounds += CVector3D(-width/2.f, 0,     -depth/2.f);
				bounds += CVector3D( width/2.f, height, depth/2.f);

				bounds.Transform(GetTransform(), m_SelectionBox);
			}
			break;
		case CustomSelectionShape::CYLINDER:
			{
				// TODO: unimplemented
				m_SelectionBox.SetEmpty();
				LOGWARNING(L"[ModelAbstract] TODO: Cylinder selection boxes are not yet implemented. Use BOX or BOUNDS selection shapes instead.");
			}
			break;
		default:
			{
				m_SelectionBox.SetEmpty();
				//LOGWARNING(L"[ModelAbstract] Unrecognized selection shape type: %ld", m_CustomSelectionShape->m_Type);
				debug_warn("[ModelAbstract] Unrecognized selection shape type");
			}
			break;
		}
	}
	else
	{
		// standard method

		// Get the object-space bounds that should be used to construct this model (and its children)'s selection box
		CBoundingBoxAligned objBounds = GetObjectSelectionBoundsRec();
		if (objBounds.IsEmpty())
		{
			m_SelectionBox.SetEmpty(); // model does not wish to participate in selection
			return;
		}

		// Prevent the bounding box from extending through the terrain; clip the lower plane at Y=0 in object space.
		if (objBounds[1].Y > 0.f) // should always be the case, unless the models are defined really weirdly
			objBounds[0].Y = std::max(0.f, objBounds[0].Y);

		// transform object-space axis-aligned bounds to world-space arbitrary-aligned box
		objBounds.Transform(GetTransform(), m_SelectionBox);
	}
	
}
Example #19
0
void _VMClass_add_instance_primitive(void* _self, pVMPrimitive value, bool warn) {
    pVMClass self = (pVMClass)_self;
    if(SEND(self, add_instance_invokable, (pVMObject)value) && warn) {
        pVMSymbol sym = TSEND(VMInvokable, value, get_signature);
        debug_warn("Primitive %s is not in class definition for class %s.\n",
                   sym->chars,
                   self->name->chars);
    }
}
Example #20
0
static void FixLocales()
{
#if OS_MACOSX || OS_BSD
	// OS X requires a UTF-8 locale in LC_CTYPE so that *wprintf can handle
	// wide characters. Peculiarly the string "UTF-8" seems to be acceptable
	// despite not being a real locale, and it's conveniently language-agnostic,
	// so use that.
	setlocale(LC_CTYPE, "UTF-8");
#endif


	// On misconfigured systems with incorrect locale settings, we'll die
	// with a C++ exception when some code (e.g. Boost) tries to use locales.
	// To avoid death, we'll detect the problem here and warn the user and
	// reset to the default C locale.


	// For informing the user of the problem, use the list of env vars that
	// glibc setlocale looks at. (LC_ALL is checked first, and LANG last.)
	const char* const LocaleEnvVars[] = {
		"LC_ALL",
		"LC_COLLATE",
		"LC_CTYPE",
		"LC_MONETARY",
		"LC_NUMERIC",
		"LC_TIME",
		"LC_MESSAGES",
		"LANG"
	};

	try
	{
		// this constructor is similar to setlocale(LC_ALL, ""),
		// but instead of returning NULL, it throws runtime_error
		// when the first locale env variable found contains an invalid value
		std::locale("");
	}
	catch (std::runtime_error&)
	{
		LOGWARNING("Invalid locale settings");

		for (size_t i = 0; i < ARRAY_SIZE(LocaleEnvVars); i++)
		{
			if (char* envval = getenv(LocaleEnvVars[i]))
				LOGWARNING("  %s=\"%s\"", LocaleEnvVars[i], envval);
			else
				LOGWARNING("  %s=\"(unset)\"", LocaleEnvVars[i]);
		}

		// We should set LC_ALL since it overrides LANG
		if (setenv("LC_ALL", std::locale::classic().name().c_str(), 1))
			debug_warn(L"Invalid locale settings, and unable to set LC_ALL env variable.");
		else
			LOGWARNING("Setting LC_ALL env variable to: %s", getenv("LC_ALL"));
	}
}
Example #21
0
static void SetTextureQuality(int quality)
{
	int q_flags;
	GLint filter;

retry:
	// keep this in sync with SANE_TEX_QUALITY_DEFAULT
	switch(quality)
	{
		// worst quality
	case 0:
		q_flags = OGL_TEX_HALF_RES|OGL_TEX_HALF_BPP;
		filter = GL_NEAREST;
		break;
		// [perf] add bilinear filtering
	case 1:
		q_flags = OGL_TEX_HALF_RES|OGL_TEX_HALF_BPP;
		filter = GL_LINEAR;
		break;
		// [vmem] no longer reduce resolution
	case 2:
		q_flags = OGL_TEX_HALF_BPP;
		filter = GL_LINEAR;
		break;
		// [vmem] add mipmaps
	case 3:
		q_flags = OGL_TEX_HALF_BPP;
		filter = GL_NEAREST_MIPMAP_LINEAR;
		break;
		// [perf] better filtering
	case 4:
		q_flags = OGL_TEX_HALF_BPP;
		filter = GL_LINEAR_MIPMAP_LINEAR;
		break;
		// [vmem] no longer reduce bpp
	case SANE_TEX_QUALITY_DEFAULT:
		q_flags = OGL_TEX_FULL_QUALITY;
		filter = GL_LINEAR_MIPMAP_LINEAR;
		break;
		// [perf] add anisotropy
	case 6:
		// TODO: add anisotropic filtering
		q_flags = OGL_TEX_FULL_QUALITY;
		filter = GL_LINEAR_MIPMAP_LINEAR;
		break;
		// invalid
	default:
		debug_warn(L"SetTextureQuality: invalid quality");
		quality = SANE_TEX_QUALITY_DEFAULT;
		// careful: recursion doesn't work and we don't want to duplicate
		// the "sane" default values.
		goto retry;
	}

	ogl_tex_set_defaults(q_flags, filter);
}
Example #22
0
void CConfigDB::SetConfigFile(EConfigNamespace ns, const VfsPath& path)
{
	if (ns < 0 || ns >= CFG_LAST)
	{
		debug_warn(L"CConfigDB: Invalid ns value");
		return;
	}

	m_ConfigFile[ns]=path;
}
Example #23
0
bool CConfigDB::WriteFile(EConfigNamespace ns)
{
	if (ns < 0 || ns >= CFG_LAST)
	{
		debug_warn(L"CConfigDB: Invalid ns value");
		return false;
	}

	return WriteFile(ns, m_ConfigFile[ns]);
}
Example #24
0
void CGUIManager::PopPage()
{
	if (m_PageStack.size() < 2)
	{
		debug_warn(L"Tried to pop GUI page when there's < 2 in the stack");
		return;
	}

	m_PageStack.pop_back();
}
Example #25
0
void CComponentManager::AddMockComponent(entity_id_t ent, InterfaceId iid, IComponent& component)
{
	// Just add it into the by-interface map, not the by-component-type map,
	// so it won't be considered for messages or deletion etc

	boost::unordered_map<entity_id_t, IComponent*>& emap1 = m_ComponentsByInterface.at(iid);
	if (emap1.find(ent) != emap1.end())
		debug_warn(L"Multiple components for interface");
	emap1.insert(std::make_pair(ent, &component));
}
Example #26
0
ActorViewer::ActorViewer()
	: m(*new ActorViewerImpl())
{
	m.WalkEnabled = false;
	m.GroundEnabled = true;
	m.WaterEnabled = false;
	m.ShadowsEnabled = g_Renderer.GetOptionBool(CRenderer::OPT_SHADOWS);
	m.SelectionBoxEnabled = false;
	m.AxesMarkerEnabled = false;
	m.PropPointsMode = 0;
	m.Background = SColor4ub(0, 0, 0, 255);

	// Create a tiny empty piece of terrain, just so we can put shadows
	// on it without having to think too hard
	m.Terrain.Initialize(2, NULL);
	CTerrainTextureEntry* tex = g_TexMan.FindTexture("whiteness");
	if (tex)
	{
		for (ssize_t pi = 0; pi < m.Terrain.GetPatchesPerSide(); ++pi)
		{
			for (ssize_t pj = 0; pj < m.Terrain.GetPatchesPerSide(); ++pj)
			{
				CPatch* patch = m.Terrain.GetPatch(pi, pj);
				for (ssize_t i = 0; i < PATCH_SIZE; ++i)
				{
					for (ssize_t j = 0; j < PATCH_SIZE; ++j)
					{
						CMiniPatch& mp = patch->m_MiniPatches[i][j];
						mp.Tex = tex;
						mp.Priority = 0;
					}
				}
			}
		}
	}
	else
	{
		debug_warn(L"Failed to load whiteness texture");
	}

	// Start the simulation
	m.Simulation2.LoadDefaultScripts();
	m.Simulation2.ResetState();

	// Tell the simulation we've already loaded the terrain
	CmpPtr<ICmpTerrain> cmpTerrain(m.Simulation2, SYSTEM_ENTITY);
	if (cmpTerrain)
		cmpTerrain->ReloadTerrain(false);

	// Remove FOW since we're in Atlas
	CmpPtr<ICmpRangeManager> cmpRangeManager(m.Simulation2, SYSTEM_ENTITY);
	if (cmpRangeManager)
		cmpRangeManager->SetLosRevealAll(-1, true);
}
Example #27
0
void ekg_disconnect_by_outstream(GDataOutputStream *f) {
	struct ekg_connection *c = get_connection_by_outstream(f);

	if (!c) {
		debug_warn("ekg_disconnect_by_outstream() - connection not found\n");
		return;
	}

	debug_function("ekg_disconnect_by_outstream(%x)\n",c);

	ekg_connection_remove(c);
}
Example #28
0
const u8* CVFSFile::GetBuffer() const
{
	// Die in a very obvious way, to avoid subtle problems caused by
	// accidentally forgetting to check that the open succeeded
	if (!m_Buffer)
	{
		debug_warn(L"GetBuffer() called with no file loaded");
		throw PSERROR_CVFSFile_InvalidBufferAccess();
	}

	return m_Buffer.get();
}
Example #29
0
void CNetTurnManager::AddCommand(int client, int player, JS::HandleValue data, u32 turn)
{
	NETTURN_LOG((L"AddCommand(client=%d player=%d turn=%d)\n", client, player, turn));

	if (!(m_CurrentTurn < turn && turn <= m_CurrentTurn + COMMAND_DELAY + 1))
	{
		debug_warn(L"Received command for invalid turn");
		return;
	}

	m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, m_Simulation2.GetScriptInterface().GetContext(), data);
}
Example #30
0
void IGUIObject::LoadStyle(CGUI& GUIinstance, const CStr& StyleName)
{
	// Fetch style
	if (GUIinstance.m_Styles.count(StyleName) == 1)
	{
		LoadStyle(GUIinstance.m_Styles[StyleName]);
	}
	else
	{
		debug_warn(L"IGUIObject::LoadStyle failed");
	}
}