diff --git a/code/modules/admin/admin.dm b/code/modules/admin/admin.dm index 74c27f30e2f..7a14927c057 100644 --- a/code/modules/admin/admin.dm +++ b/code/modules/admin/admin.dm @@ -174,16 +174,18 @@ var/global/floorIsLava = 0 /datum/player_info/var/timestamp // Because this is bloody annoying #define PLAYER_NOTES_ENTRIES_PER_PAGE 50 -/datum/admins/proc/PlayerNotes(var/page = 1) +/datum/admins/proc/PlayerNotes() set category = "Admin" set name = "Player Notes" - var/dat = "Player notes
" if (!istype(src,/datum/admins)) src = usr.client.holder if (!istype(src,/datum/admins)) usr << "Error: you are not an admin!" return + PlayerNotesPage(1) +/datum/admins/proc/PlayerNotesPage(page) + var/dat = "Player notes
" var/savefile/S=new("data/player_notes.sav") var/list/note_keys S >> note_keys @@ -195,14 +197,17 @@ var/global/floorIsLava = 0 // Display the notes on the current page var/number_pages = note_keys.len / PLAYER_NOTES_ENTRIES_PER_PAGE + // Emulate ceil(why does BYOND not have ceil) + if(number_pages != round(number_pages)) + number_pages = round(number_pages) + 1 var/page_index = page - 1 if(page_index < 0 || page_index >= number_pages) return - for(var/index = page_index * PLAYER_NOTES_ENTRIES_PER_PAGE + 1, \ - index <= (page_index + 1) * PLAYER_NOTES_ENTRIES_PER_PAGE, \ - index++) - + var/lower_bound = page_index * PLAYER_NOTES_ENTRIES_PER_PAGE + 1 + var/upper_bound = (page_index + 1) * PLAYER_NOTES_ENTRIES_PER_PAGE + upper_bound = min(upper_bound, note_keys.len) + for(var/index = lower_bound, index <= upper_bound, index++) var/t = note_keys[index] dat += "[t]" @@ -1146,4 +1151,4 @@ proc/move_alien_ship() alien_ship_location = 0 else alien_ship_location = 1 - return \ No newline at end of file + return diff --git a/code/modules/admin/holder2.dm b/code/modules/admin/holder2.dm index 3d2c506ae48..9f9e9abd3fa 100644 --- a/code/modules/admin/holder2.dm +++ b/code/modules/admin/holder2.dm @@ -2707,5 +2707,5 @@ var/list/admin_datums = list() if("show") show_player_info(ckey) if("list") - PlayerNotes(href_list["index"]) + PlayerNotesPage(href_list["index"]) return