Exemplo n.º 1
0
// Count the number of chunks this player has
func countChunks(db *mysql.Client, uid uint32) int {
	// Build a query for the given chunk coordinate as an argument
	query := fmt.Sprintf("SELECT * FROM chunkdata WHERE avatarID=%d", uid)
	err := db.Query(query)
	if err != nil {
		// Fatal error
		log.Println(err)
		return ConfigHandicapLimit
	}

	// Store the result
	result, err := db.StoreResult()
	if err != nil {
		log.Println(err)
		return ConfigHandicapLimit
	}
	numRows := result.RowCount()

	db.FreeResult()
	return int(numRows)
}