コード例 #1
0
ファイル: procs.go プロジェクト: xushiwei/ephenation-server
// Control monsters attacking players
func ProcMonsterMelee_RLmBl() {
	var elapsed time.Duration
	timerstats.Add("ProcMonsterMeelee", CnfgAttackPeriod, &elapsed)
	for {
		start := time.Now()
		time.Sleep(CnfgAttackPeriod)
		CmdMonsterMelee_RLm()
		elapsed = time.Now().Sub(start)
	}
}
コード例 #2
0
ファイル: procs.go プロジェクト: xushiwei/ephenation-server
func ProcSpawnMonsters_WLwWLuWLqWLmBlWLc() {
	var elapsed time.Duration
	timerstats.Add("ProcSpawnMonsters", SPAWN_MONSTER_PERIOD, &elapsed)
	for {
		start := time.Now()
		time.Sleep(SPAWN_MONSTER_PERIOD)
		CmdSpawnMonsters_WLwWLuWLqWLmWLc()
		elapsed = time.Now().Sub(start)
	}
}
コード例 #3
0
ファイル: procs.go プロジェクト: xushiwei/ephenation-server
func ProcPurgeMonsters_WLmWLqBl() {
	var elapsed time.Duration
	timerstats.Add("ProcPurgeMonsters", PURGE_MONSTER_PERIOD, &elapsed)
	for {
		start := time.Now()
		time.Sleep(PURGE_MONSTER_PERIOD)
		CmdPurgeMonsters_WLmWLq()
		elapsed = time.Now().Sub(start)
	}
}
コード例 #4
0
ファイル: procs.go プロジェクト: xushiwei/ephenation-server
func ProcUpdateMonstersTarget_RLmRLqBl() {
	var elapsed time.Duration
	timerstats.Add("ProcUpdateMonstersTarget", MonstersUpdateTargetPeriod, &elapsed)
	for {
		start := time.Now()
		time.Sleep(MonstersUpdateTargetPeriod)
		UpdateAllMonstersTarget_RLmRLq()
		elapsed = time.Now().Sub(start)
	}
}
コード例 #5
0
ファイル: procs.go プロジェクト: xushiwei/ephenation-server
func ProcUpdateMonsterState() {
	var elapsed time.Duration
	timerstats.Add("ProcUpdateMonsterState", MonstersUpdateDirPeriod, &elapsed)
	lastTime := time.Now()
	for {
		start := time.Now()
		time.Sleep(MonstersUpdateDirPeriod)
		if start.Sub(lastTime) > 4e9 {
			lastTime = start
		}
		UpdateAllMonstersState()
		elapsed = time.Now().Sub(start)
	}
}
コード例 #6
0
ファイル: procs.go プロジェクト: xushiwei/ephenation-server
// Autosave of players
func ProcAutosave_RLu() {
	var elapsed time.Duration
	timerstats.Add("ProcAutosave", CnfgAutosavePeriod, &elapsed)
	for {
		start := time.Now()
		oldMajor, oldMinor := ClientCurrentMajorVersion, ClientCurrentMinorVersion
		ClientCurrentMajorVersion, ClientCurrentMinorVersion = LoadClientVersionInformation("clientversion.txt")
		if (oldMajor != ClientCurrentMajorVersion || oldMinor != ClientCurrentMinorVersion) && *verboseFlag > 0 {
			log.Printf("New client version %d.%d\n", ClientCurrentMajorVersion, ClientCurrentMinorVersion)
		}
		time.Sleep(CnfgAutosavePeriod)
		SaveAllPlayers_RLa()
		elapsed = time.Now().Sub(start)
	}
}
コード例 #7
0
ファイル: procs.go プロジェクト: xushiwei/ephenation-server
func ProcUpdateMonsterPos_RLmWLwWLqBlWLuWLc() {
	var elapsed time.Duration
	timerstats.Add("ProcUpdateMonsterPos", ObjectsUpdatePeriod, &elapsed)
	lastTime := time.Now()
	for {
		start := time.Now()
		time.Sleep(ObjectsUpdatePeriod) // TODO: Monsters could move at a lower frequency than players
		fullReport := false
		if start.Sub(lastTime) > 4e9 {
			// Request a full report, but not too often as it generates much traffic
			fullReport = true
			lastTime = start
		}
		UpdateAllMonsterPos_RLmWLwWLqWLuWLc(fullReport)
		elapsed = time.Now().Sub(start)
	}
}
コード例 #8
0
ファイル: score.go プロジェクト: hycxa/ephenation-server
//
// A process that will manage the decay of all entries, and save to the database as needed.
//
func maintainScore() {
	var elapsed time.Duration // Used to measure performance of this process
	timerstats.Add("Score maintenance", ConfigScoreUpdatePeriod, &elapsed)
	var list []*territoryScore // Use a linear copy of all pointers so that the map doesn't have to be locked.
	defer procStatus.Done()
	// Stay in this loop until system shuts down (using the tomb control)
	for {
		start := time.Now()
		timer := time.NewTimer(ConfigScoreUpdatePeriod) // Used as the ticker to activate the process regularly
	again:
		select {
		case <-procStatus.Dying():
			update(list) // Save any remaining data not updated before terminating
			return
		case ts := <-chScoreList: // This is the way new entries are received
			list = append(list, ts)
			goto again // Don't start a new timer
		case <-timer.C:
			update(list)
			elapsed = time.Now().Sub(start) // For statistics only
		}
	}
}