This commit is contained in:
Bohdan Kapliuk 2024-11-03 17:15:59 +02:00
parent 5472c7fa71
commit 641cf50bc0

View File

@ -29,10 +29,12 @@ void destroy_station(struct station* station){
int select_track(struct station* station, const char* target) { int select_track(struct station* station, const char* target) {
unsigned long hash = 5381; unsigned long hash = 5381;
int c; int c;
while (c = *target++)
hash = ((hash << 5) + hash) + c;
return hash; while ((c = *target++)) {
hash = ((hash << 5) + hash) + c;
}
return hash % station->track_count;
} }
void add_target_capacity(struct station* station,const char* target, int capacity){ void add_target_capacity(struct station* station,const char* target, int capacity){