예제 #1
0
파일: Server.cs 프로젝트: floatyears/CodeX
	public override void Init()
	{
		instance = this;
		clients = new ClientNode[CConstVar.MAX_CLIENTS];
		for(int i = 0; i < CConstVar.MAX_CLIENTS; i++){
			clients[i] = new ClientNode();
		}
		svEntities = new SvEntityState[CConstVar.MAX_GENTITIES];
		for(int i = 0; i < CConstVar.MAX_GENTITIES; i++){
			svEntities[i] = new SvEntityState();
		}
		// gEntities = new SharedEntity[CConstVar.MAX_GENTITIES];
		// for(int i = 0; i < CConstVar.MAX_GENTITIES; i++){
		// 	gEntities[i] = new SharedEntity();
		// }
		worldSectors = new WorldSector[64];
		for(int i = 0; i < 64; i++){
			worldSectors[i] = new WorldSector();
		}

		configString = new string[CConstVar.MAX_CONFIGSTRINGS];
		serverRunning = false;

		challenges = new SvChallenge[CConstVar.MAX_CHALLENGES];
		for(int i = 0; i < CConstVar.MAX_CHALLENGES; i++){
			challenges[i] = new SvChallenge();
		}

		numSnapshotEntities = CConstVar.MAX_CLIENTS * CConstVar.PACKET_BACKUP * CConstVar.MAX_SNAPSHOT_ENTITIES;
		snapshotEntities = new EntityState[numSnapshotEntities];
		inited = true;
	}
예제 #2
0
파일: Server.cs 프로젝트: floatyears/CodeX
	public void UnLinkEntity(GameEntity gEnt){
		SvEntityState ent = GetSvEntityForGentity(gEnt);
		gEnt.sEnt.r.linked = false;

		WorldSector ws = ent.worldSector;
		if(ws == null){
			return;
		}

		ent.worldSector = null;

		if(ws.entities == ent){
			ws.entities = ent.nextEntityInWorldSector;
			return;
		}

		SvEntityState scan;
		for(scan = ws.entities; scan != null; scan = scan.nextEntityInWorldSector){
			if(scan.nextEntityInWorldSector == ent){
				scan.nextEntityInWorldSector = ent.nextEntityInWorldSector;
				return;
			}
		}
		CLog.Warning("UnlinkEntity: not found in worldSector!");
	}
예제 #3
0
파일: Server.cs 프로젝트: floatyears/CodeX
	private void AddEntToSnapshot(SvEntityState svEntity, SharedEntity gEnt, List<int> entitiesIndex){
		//如果已经添加了,就不再次添加
		if(svEntity.snapshotCounter == snapshotCounter){
			return;
		}
		svEntity.snapshotCounter = snapshotCounter;
		if(entitiesIndex.Count >= CConstVar.MAX_SNAPSHOT_ENTITIES){
			return;
		}
		entitiesIndex.Add(gEnt.s.entityIndex);
	}
예제 #4
0
파일: Server.cs 프로젝트: floatyears/CodeX
	public void LinkEntity(GameEntity gEnt){
		int i,j,k;
		SvEntityState ent = GetSvEntityForGentity(gEnt);
		if(ent.worldSector != null){
			UnLinkEntity(gEnt);
		}
		if(gEnt.sEnt.r.bmodel){
			gEnt.sEnt.s.solid = CConstVar.SOLID_BMODEL;
		}else if((gEnt.sEnt.r.contents & (CConstVar.CONTENTS_SOLID | CConstVar.CONTENTS_BODY)) > 0){
			i = (int)gEnt.sEnt.r.maxs[0];
			if(i < 1){
				i = 1;
			}
			if(i > 255){
				i = 255;
			}
		}

		Vector3 origin = gEnt.sEnt.r.currentOrigin;
		Vector3 angles = gEnt.sEnt.r.currentAngles;

		// if(gEnt.sEnt.r.bmodel && (angles[0] > 0f || angles[1] > 0f || angles[2] > 0f)){
		// 	flo
		// }
		ent.numClusters = 0;
		// ent.lastclu
		gEnt.sEnt.r.linkCount++;
		WorldSector node = worldSectors[0];
		while(true){
			if(node.axis == -1){
				break;
			}
			if(gEnt.sEnt.r.absmin[node.axis] > node.dist){
				node = node.children[0];
			}else if(gEnt.sEnt.r.absmax[node.axis] < node.dist){
				node = node.children[1];
			}else
			{
				break;
			}
		}
		ent.worldSector = node;
		ent.nextEntityInWorldSector = node.entities;
		node.entities = ent;
		gEnt.sEnt.r.linked = true;
	}