Пример #1
0
ati_t * ATI_CreateItem( hobj_t *item_obj )
{
	at_item_t		*item;

	if ( strcmp( item_obj->type, "item" ) )
		__error( "item_obj is not of type 'item'\n" );

	if ( ftbl_valid == false )
	{
		ftbl_valid = true;
		INITTYPE( &ftbl, ati_ftbl_t );

		ftbl.Destroy = DestroyItem;
		ftbl.Com = ComItem;
		ftbl.UnpackEvent = NULL;
		ftbl.Run = RunItem;
	}

	item = NEWTYPE( at_item_t );

	item->atif.ftbl = &ftbl;
	item->atif.id = StringToUnique( item_obj->name );
	item->atif.ati_obj = item_obj;
	item->atif.frame_count = 0;       

	return &item->atif;
}
Пример #2
0
/*
  ==============================
  G_InitClient

  ==============================
*/
void G_InitClient( g_client_t *cl )
{
	INITTYPE( cl, g_client_t );

	cl->state = gClientState_try_init;

	SHV_Printf( "\n" );
	SHV_Printf( " --- Init Client ---\n" );

	__chkptr( cl );


	sprintf( cl->lib.name, "cl" );
	if ( G_LibLoad( &cl->lib ) )
	{
		__error( "can't load client dll\n" );
	}
	cl->lib.api.Init();

	cl->lib.api.Com( "CL_WorldSpring" );
//	ImportLife( "dd1" );
//	le.L_StartUp();

//	tmp = SHP_GetVar( "gc_map" );
//	__named_message( "gc_map is '%s'\n", tmp->string );
//	le.WorldSpring( tmp->string );	

	cl->mode = gClientMode_local;
	cl->state = gClientState_is_init;

	G_ClientResetInput( cl );

	SHV_Printf( "\n" );
	SHV_Printf( " --- Init Client done ---\n" );	
}
Пример #3
0
/*
  ==============================
  TriMesh_Init

  ==============================
*/
void TriMesh_Init( trimesh_t *mesh )
{
	INITTYPE( mesh, trimesh_t );
	
	U_InitMap( &mesh->knot_map, map_default, CompareUniques, KnotGetPrimaryKey );
	U_InitMap( &mesh->tri_map, map_default, CompareUniques, TriGetPrimaryKey );
	U_InitList( &mesh->vertex_list );
}
Пример #4
0
/*
  ==============================
  G_InitServer

  ==============================
*/
void G_InitServer( g_server_t *sv )
{
	sh_var_t		*tmp;

	INITTYPE( sv, g_server_t );

	sv->state = gServerState_try_init;

	SHV_Printf( "\n" );
	SHV_Printf( " --- Init Server ---\n" );

	__chkptr( sv );

	tmp = SHP_GetVar( "gc_servermode" );
	
	__named_message( "gc_servermode is '%s'\n", tmp->string );
	if ( !strcmp( tmp->string, "local" ) )
	{
		//
		// load server dll
		//
		sprintf( sv->lib.name, "sv" );
		if ( G_LibLoad( &sv->lib ) )
		{
			__error( "can't load server dll\n" );			
		}

		sv->lib.api.Init();

		sv->lib.api.Com( "SV_WorldSpring" );

		sv->mode = gServerMode_local;
		sv->state = gServerState_is_init;
	}
	else if ( !strcmp( tmp->string, "remote" ) )
	{
		sv->mode = gServerMode_remote;
		sv->state = gServerState_is_init;
	}
	else
	{
		__error( "shvar 'gc_servermode' is invalide\n" );
	}

	G_ServerResetInput( sv );

	SHV_Printf( "\n" );
	SHV_Printf( " --- Init Server done ---\n" );

}
Пример #5
0
cl_ati_t * CL_CreateRocket( unique_t id, byte_iter_t *bi )
{
	cl_at_rocket_t		*rocket;

	if ( ftbl_valid == false )
	{
		ftbl_valid = true;
		INITTYPE( &ftbl, cl_ati_ftbl_t );

		ftbl.Destroy = DestroyRocket;
		ftbl.UnpackEvent = UnpackEventRocket;
		ftbl.Run = RunRocket;
	}

	rocket = NEWTYPE( cl_at_rocket_t );
	rocket->atif.ftbl = &ftbl;
	rocket->atif.id = id;

	return &rocket->atif;
}
Пример #6
0
cl_ati_t * CL_CreateItem( unique_t id, byte_iter_t *bi )
{
	cl_at_item_t		*item;

	if ( ftbl_valid == false )
	{
		ftbl_valid = true;
		INITTYPE( &ftbl, cl_ati_ftbl_t );

		ftbl.Destroy = DestroyItem;
		ftbl.UnpackEvent = UnpackEventItem;
		ftbl.Run = RunItem;
	}

	item = NEWTYPE( cl_at_item_t );
	item->atif.ftbl = &ftbl;
	item->atif.id = id;

	// init private data from byte_iter event
	item->style = itemStyle_none;

	return &item->atif;
}
Пример #7
0
cl_ati_t * CL_CreateSwitch( hobj_t *obj_switch )
{
	cl_at_switch_t	*_switch;

	if ( ftbl_valid == false )
	{
		ftbl_valid = true;
		INITTYPE( &ftbl, cl_ati_ftbl_t );

		ftbl.Destroy = DestroySwitch;
		ftbl.UnpackEvent = UnpackEventSwitch;
		ftbl.Run = RunSwitch;
	}

	_switch = NEWTYPE( cl_at_switch_t );
	_switch->atif.ftbl = &ftbl;
	_switch->atif.id = StringToUnique( obj_switch->name );
	_switch->atif.ati_obj = obj_switch;

	_switch->atif.frame_count = 0;

	return &_switch->atif;
}
Пример #8
0
/*
  ==============================
  G_InitMap

  ==============================
*/
void G_InitMap( g_map_t *map )
{
//	g_map_t		*map;

	char		lightmap_bin[256];
	char		lightmap_class[256];
	char		lightsource_class[256];
	char		tt[256];
	char		path[256];
	tokenstream_t	*ts;

	sh_var_t		*tmp;

	INITTYPE( map, g_map_t );
	map->state = gMapState_try_init;

	SHV_Printf( "\n" );
	SHV_Printf( " --- Init Map ---\n" );

	tmp = SHP_GetVar( "gc_map" );
	SHV_Printf( "gc_map is '%s'\n", tmp->string );

	sprintf( path, "world/%s.d/fake", tmp->string );
	SHV_Printf( "path: '%s'\n", path );

//	SHV_Printf( "create new game map\n" );
//	map = NEWTYPE( g_map_t );

	//
	// load multilayer defs
	//
	SHV_Printf( "load multilayer definition class\n" );
	{
		hobj_t		*root;

		ts = BeginTokenStream( "shape_config/multilayer.hobj" );
		if ( !ts )
			__error( "can't open shape_config/multilayer.hobj" );
		root = ReadClass( ts );
		EndTokenStream( ts );

	        map->multilayerhm = NewFlatHManagerFromClass( root );
	}

	// 
	// bsp classes
	//

	printf( "load map classes\n" );
	G_SpawnMap( map, path );

	printf( "setup map data\n" );
	R_InitData( map );


	//
	// load lightmap database
	//

	printf( "setup lightmap database\n" );
	
#if 0
    map->lightmap_db = NEWTYPE( db_lightmap_t );
	LightmapDB_Init( map->lightmap_db );
	sprintf( lightmap_bin, "%s/%s", path, MAP_BIN_NAME_LIGHTMAP );
	sprintf( lightmap_class, "%s/%s", path, MAP_CLASS_NAME_LIGHTMAP );
	sprintf( lightsource_class, "%s/%s", path, "_light_source.class" );
	LightmapDB_Load( map->lightmap_db, lightmap_bin, lightmap_class, lightsource_class  );
#else
    sprintf( lightmap_bin, "%s/%s", path, MAP_BIN_NAME_LIGHTMAP );
    sprintf( lightmap_class, "%s/%s", path, MAP_CLASS_NAME_LIGHTMAP );
    sprintf( lightsource_class, "%s/%s", path, "_light_source.hobj" );

    map->lightmap_db = new lightmap_db_cpp(lightmap_bin, lightmap_class, lightsource_class);
    
    //LightmapDB_Load( map->lightmap_db, lightmap_bin, lightmap_class, lightsource_class  );
//     map->lightmap_db->load( lightmap_bin, lightmap_class, lightsource_class );
    
#endif
	//
	// init shape database
	//
	
	printf( "setup shape database\n" );
	map->shape_db = NEWTYPE( db_shape_t );
	ShapeDB_Init( map->shape_db );

	//
	// load glmesh binary
	//
	{
		int		filesize;
		ib_file_t	*h;

		sprintf( tt, "%s/%s", path, MAP_BIN_NAME_GLMESH );
		h = IB_Open( tt );
		if ( !h )
			__error( "can't open glmesh binary\n" );
		
		filesize = IB_GetSize( h );
		map->glmesh = (unsigned char *)NEWBYTES( filesize );
		IB_Read( map->glmesh, filesize, 1, h );
		IB_Close( h );		
	}
	
	//
	// render stuff
	//

	printf( "setup subimage cache\n" );
	map->imgcache = IC_NewMgr( 128, 128, 64+32 );
	printf( "setup shader manager\n" );
	map->shader_mgr = Shader_NewMgr();

	printf( "setup shapes\n" );
	R_SetupShapes( map );

	R_InitGLResources();

	SHV_Printf( "\n" );
	SHV_Printf( "setup tesselation ...\n" );

	// sort the shapes into the bsp tree
	R_SetupShapeRefs();	// render3.c
	SHV_Printf( "\n" );

	G_InitData( map );

	R_AllShapesLoadLightmaps();

	SHV_Printf( "\n" );
	SHV_Printf( " --- Init Map done ---\n" );


	map->state = gMapState_is_init;
//	return map;
}
Пример #9
0
v_kernel
v_kernelNew(
    c_base base,
    const c_char *name,
    v_kernelQos qos)
{
    v_kernel kernel;
    v_kernelStatistics kernelStatistics;
    v_spliced sd;

    kernel = c_lookup(base,name);
    if (kernel != NULL) {
        assert(C_TYPECHECK(kernel,v_kernel));
        kernel->userCount++;
        return kernel;
    }

    loadkernelModule(base);

    kernel = (v_kernel)c_new(c_resolve(base,"kernelModule::v_kernel"));
    if (!kernel) {
        OS_REPORT(OS_ERROR,
                  "v_kernelNew",0,
                  "Failed to allocate kernel.");
        return NULL;
    }
    v_objectKind(kernel) = K_KERNEL;
    v_object(kernel)->kernel = (c_voidp)kernel;
    kernel->handleServer = v_handleServerNew(base);

#define INITTYPE(k,t,l) k->type[l] = c_resolve(base,#t)

    INITTYPE(kernel,kernelModule::v_kernel,             K_KERNEL);
    INITTYPE(kernel,kernelModule::v_participant,        K_PARTICIPANT);
    INITTYPE(kernel,kernelModule::v_waitset,            K_WAITSET);
    INITTYPE(kernel,kernelModule::v_condition,          K_CONDITION);
    INITTYPE(kernel,kernelModule::v_query,              K_QUERY);
    INITTYPE(kernel,kernelModule::v_dataReaderQuery,    K_DATAREADERQUERY);
    INITTYPE(kernel,kernelModule::v_dataViewQuery,      K_DATAVIEWQUERY);
    INITTYPE(kernel,kernelModule::v_dataView,           K_DATAVIEW);
    INITTYPE(kernel,kernelModule::v_dataViewSample,     K_DATAVIEWSAMPLE);
    INITTYPE(kernel,kernelModule::v_dataViewInstance,   K_DATAVIEWINSTANCE);
    INITTYPE(kernel,kernelModule::v_projection,         K_PROJECTION);
    INITTYPE(kernel,kernelModule::v_mapping,            K_MAPPING);
    INITTYPE(kernel,kernelModule::v_topic,              K_TOPIC);
    INITTYPE(kernel,kernelModule::v_message,            K_MESSAGE);
    INITTYPE(kernel,kernelModule::v_transaction,        K_TRANSACTION);
    INITTYPE(kernel,kernelModule::v_dataReaderInstance, K_DATAREADERINSTANCE);
    INITTYPE(kernel,kernelModule::v_purgeListItem,      K_PURGELISTITEM);
    INITTYPE(kernel,kernelModule::v_groupPurgeItem,     K_GROUPPURGEITEM);
    INITTYPE(kernel,kernelModule::v_dataReaderSample,   K_READERSAMPLE);
    INITTYPE(kernel,kernelModule::v_publisher,          K_PUBLISHER);
    INITTYPE(kernel,kernelModule::v_subscriber,         K_SUBSCRIBER);
    INITTYPE(kernel,kernelModule::v_partition,             K_DOMAIN);
    INITTYPE(kernel,kernelModule::v_partitionInterest,     K_DOMAININTEREST);
    INITTYPE(kernel,kernelModule::v_partitionAdmin,        K_DOMAINADMIN);
    INITTYPE(kernel,kernelModule::v_reader,             K_READER);
    INITTYPE(kernel,kernelModule::v_writer,             K_WRITER);
    INITTYPE(kernel,kernelModule::v_writerGroup,        K_WRITERGROUP);
    INITTYPE(kernel,kernelModule::v_group,              K_GROUP);
    INITTYPE(kernel,kernelModule::v_groupInstance,      K_GROUPINSTANCE);
    INITTYPE(kernel,kernelModule::v_groupSample,        K_GROUPSAMPLE);
    INITTYPE(kernel,kernelModule::v_groupCacheItem,     K_GROUPCACHEITEM);
    INITTYPE(kernel,kernelModule::v_cache,              K_CACHE);
    INITTYPE(kernel,kernelModule::v_entry,              K_ENTRY);
    INITTYPE(kernel,kernelModule::v_dataReaderEntry,    K_DATAREADERENTRY);
    INITTYPE(kernel,kernelModule::v_groupAction,        K_GROUPACTION);
    INITTYPE(kernel,kernelModule::v_groupStream,        K_GROUPSTREAM);
    INITTYPE(kernel,kernelModule::v_groupQueue,         K_GROUPQUEUE);
    INITTYPE(kernel,kernelModule::v_groupQueueSample,   K_GROUPQUEUESAMPLE);
    INITTYPE(kernel,kernelModule::v_dataReader,         K_DATAREADER);
    INITTYPE(kernel,kernelModule::v_deliveryService,    K_DELIVERYSERVICE);
    INITTYPE(kernel,kernelModule::v_deliveryServiceEntry, K_DELIVERYSERVICEENTRY);
    INITTYPE(kernel,kernelModule::v_index,              K_INDEX);
    INITTYPE(kernel,kernelModule::v_filter,             K_FILTER);
    INITTYPE(kernel,kernelModule::v_readerStatus,       K_READERSTATUS);
    INITTYPE(kernel,kernelModule::v_writerStatus,       K_WRITERSTATUS);
    INITTYPE(kernel,kernelModule::v_partitionStatus,    K_DOMAINSTATUS);
    INITTYPE(kernel,kernelModule::v_topicStatus,        K_TOPICSTATUS);
    INITTYPE(kernel,kernelModule::v_subscriberStatus,   K_SUBSCRIBERSTATUS);
    INITTYPE(kernel,kernelModule::v_status,             K_PUBLISHERSTATUS);
    INITTYPE(kernel,kernelModule::v_status,             K_PARTICIPANTSTATUS);
    INITTYPE(kernel,kernelModule::v_kernelStatus,       K_KERNELSTATUS);
    INITTYPE(kernel,kernelModule::v_readerStatistics,   K_READERSTATISTICS);
    INITTYPE(kernel,kernelModule::v_writerStatistics,   K_WRITERSTATISTICS);
    INITTYPE(kernel,kernelModule::v_queryStatistics,    K_QUERYSTATISTICS);
    INITTYPE(kernel,kernelModule::v_lease,              K_LEASE);
    INITTYPE(kernel,kernelModule::v_leaseAction,        K_LEASEACTION);
    INITTYPE(kernel,kernelModule::v_serviceManager,     K_SERVICEMANAGER);
    INITTYPE(kernel,kernelModule::v_service,            K_SERVICE);
    INITTYPE(kernel,kernelModule::v_serviceState,       K_SERVICESTATE);
    INITTYPE(kernel,kernelModule::v_networking,         K_NETWORKING);
    INITTYPE(kernel,kernelModule::v_durability,         K_DURABILITY);
    INITTYPE(kernel,kernelModule::v_cmsoap,             K_CMSOAP);
    INITTYPE(kernel,kernelModule::v_leaseManager,       K_LEASEMANAGER);
    INITTYPE(kernel,kernelModule::v_groupSet,           K_GROUPSET);
    INITTYPE(kernel,kernelModule::v_proxy,              K_PROXY);
    INITTYPE(kernel,kernelModule::v_waitsetEvent,       K_WAITSETEVENT);
    INITTYPE(kernel,kernelModule::v_waitsetEventHistoryDelete,  K_WAITSETEVENTHISTORYDELETE);
    INITTYPE(kernel,kernelModule::v_waitsetEventHistoryRequest, K_WAITSETEVENTHISTORYREQUEST);
    INITTYPE(kernel,kernelModule::v_waitsetEventPersistentSnapshot, K_WAITSETEVENTPERSISTENTSNAPSHOT);
    INITTYPE(kernel,kernelModule::v_writerSample,       K_WRITERSAMPLE);
    INITTYPE(kernel,kernelModule::v_writerInstance,     K_WRITERINSTANCE);
    INITTYPE(kernel,kernelModule::v_writerInstanceTemplate, K_WRITERINSTANCETEMPLATE);
    INITTYPE(kernel,kernelModule::v_writerCacheItem,    K_WRITERCACHEITEM);
    /* Networking types */
    INITTYPE(kernel,kernelModule::v_networkReader,      K_NETWORKREADER);
    INITTYPE(kernel,kernelModule::v_networkReaderEntry, K_NETWORKREADERENTRY);
    INITTYPE(kernel,kernelModule::v_networkMessage,     K_NETWORKMESSAGE);
    INITTYPE(kernel,kernelModule::v_networkMapEntry,    K_NETWORKMAPENTRY);

    INITTYPE(kernel,kernelModule::v_spliced,            K_SPLICED);
    INITTYPE(kernel,kernelModule::v_configuration,      K_CONFIGURATION);
    INITTYPE(kernel,kernelModule::v_registration,       K_REGISTRATION);

    INITTYPE(kernel,kernelModule::v_historicalDataRequest,K_HISTORICALDATAREQUEST);
    INITTYPE(kernel,kernelModule::v_persistentSnapshotRequest,K_PERSISTENTSNAPSHOTREQUEST);
    INITTYPE(kernel,kernelModule::v_pendingDisposeElement,K_PENDINGDISPOSEELEMENT);

#undef INITTYPE


    kernel->pendingDisposeList =
       c_listNew(v_kernelType(kernel, K_PENDINGDISPOSEELEMENT ));
    c_mutexInit(&kernel->pendingDisposeListMutex, SHARED_MUTEX);

    kernelStatistics = v_kernelStatisticsNew(kernel);
    v_observableInit(v_observable(kernel),
                     V_KERNEL_VERSION,
                     v_statistics(kernelStatistics),
                     TRUE);
    c_lockInit(&kernel->lock,SHARED_LOCK);
    kernel->qos = v_kernelQosNew(kernel, qos);
    {
        os_time time;
        /* Fill GID with 'random' value */
        memset(&kernel->GID, 0, sizeof(kernel->GID));
        time = os_timeGet();
        kernel->GID.systemId = time.tv_nsec;
    }
    kernel->participants = c_setNew(v_kernelType(kernel,K_PARTICIPANT));
    kernel->partitions = c_tableNew(v_kernelType(kernel,K_DOMAIN),"name");
    kernel->topics = c_tableNew(v_kernelType(kernel,K_TOPIC),"name");
    kernel->groupSet = v_groupSetNew(kernel);
    kernel->serviceManager = v_serviceManagerNew(kernel);
    kernel->livelinessLM = v_leaseManagerNew(kernel);
    kernel->configuration = NULL;
    kernel->userCount = 1;
    kernel->transactionCount = 0;
    kernel->splicedRunning = TRUE;
    kernel->maxSamplesWarnLevel = V_KERNEL_MAX_SAMPLES_WARN_LEVEL_DEF;
    kernel->maxSamplesWarnShown = FALSE;
    kernel->maxSamplesPerInstanceWarnLevel = V_KERNEL_MAX_SAMPLES_PER_INSTANCES_WARN_LEVEL_DEF;
    kernel->maxSamplesPerInstanceWarnShown = FALSE;
    kernel->maxInstancesWarnLevel = V_KERNEL_MAX_INSTANCES_WARN_LEVEL_DEF;
    kernel->maxInstancesWarnShown = FALSE;
    kernel->enabledStatisticsCategories =
        c_listNew(c_resolve(base, "kernelModule::v_statisticsCategory"));

    c_mutexInit(&kernel->sharesMutex, SHARED_MUTEX);
    kernel->shares = c_tableNew(v_kernelType(kernel,K_SUBSCRIBER),
                                "qos.share.name");

    kernel->crc = v_crcNew(kernel, V_CRC_KEY);
    kernel->builtin = v_builtinNew(kernel);

    kernel->deliveryService = NULL;

    sd = v_splicedNew(kernel);
    c_free(sd);


    c_bind(kernel,name);

    return kernel;
}