about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-02-17 00:29:38 +0100
committerEmile <hanemile@protonmail.com>2019-02-17 00:29:38 +0100
commit5bf3571855448d47da788ee9a628def96481c8ec (patch)
tree896558db76d3768e744a7048451a8e2e9702bbe1
parent11c63a16d2e8431651dc32bb896ddc97854ce508 (diff)
implemented a function getting a stars timestep
-rw-r--r--db_actions.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/db_actions.go b/db_actions.go
index 1e5689b..c6ed041 100644
--- a/db_actions.go
+++ b/db_actions.go
@@ -524,6 +524,20 @@ func GetStar(starID int64) structs.Star2D {
 	return star
 }
 
+// getStarIDTimestep returns the timestep the given starID is currently inside of
+func GetStarIDTimestep(starID int64) int64 {
+	var timestep int64
+
+	// get the star from the stars table
+	query := fmt.Sprintf("SELECT timestep FROM nodes WHERE star_id=%d", starID)
+	err := db.QueryRow(query).Scan(&timestep)
+	if err != nil {
+		log.Fatalf("[ E ] GetStar query: %v \n\t\t\tquery: %s\n", err, query)
+	}
+
+	return timestep
+}
+
 // getStarMass returns the mass if the star with the given ID
 func getStarMass(starID int64) float64 {
 	var mass float64