From b79ac804a89a102adae3507cef2942d0d5482782 Mon Sep 17 00:00:00 2001 From: Arokha Sieyes Date: Mon, 19 Mar 2018 14:23:58 -0400 Subject: [PATCH] Refator init_belly() into init_vore() And make sure it doesn't run when unnecessary. --- .../station/protean_vr/protean_blob.dm | 3 ++ .../living/simple_animal/animals/cat_vr.dm | 2 +- .../living/simple_animal/animals/fox_vr.dm | 4 +- .../living/simple_animal/simple_animal_vr.dm | 24 ++++------ .../simple_animal/vore/shadekin/shadekin.dm | 6 +-- code/modules/vore/eating/living_vr.dm | 47 +++++++++++-------- 6 files changed, 45 insertions(+), 41 deletions(-) diff --git a/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_blob.dm b/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_blob.dm index 9e75d2563c8..438a805b9c2 100644 --- a/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_blob.dm +++ b/code/modules/mob/living/carbon/human/species/station/protean_vr/protean_blob.dm @@ -69,6 +69,9 @@ healing.expire() return ..() +/mob/living/simple_animal/protean_blob/init_vore() + return //Don't make a random belly, don't waste your time + /mob/living/simple_animal/protean_blob/Stat() ..() if(statpanel("Status")) diff --git a/code/modules/mob/living/simple_animal/animals/cat_vr.dm b/code/modules/mob/living/simple_animal/animals/cat_vr.dm index b2d5c73e5c2..1c9203126a3 100644 --- a/code/modules/mob/living/simple_animal/animals/cat_vr.dm +++ b/code/modules/mob/living/simple_animal/animals/cat_vr.dm @@ -1,4 +1,4 @@ -/mob/living/simple_animal/cat/fluff/Runtime/init_belly() +/mob/living/simple_animal/cat/fluff/Runtime/init_vore() ..() var/obj/belly/B = vore_selected B.name = "Stomach" diff --git a/code/modules/mob/living/simple_animal/animals/fox_vr.dm b/code/modules/mob/living/simple_animal/animals/fox_vr.dm index 90131fc8b97..587a64d14cc 100644 --- a/code/modules/mob/living/simple_animal/animals/fox_vr.dm +++ b/code/modules/mob/living/simple_animal/animals/fox_vr.dm @@ -39,7 +39,7 @@ var/turns_since_scan = 0 var/mob/flee_target -/mob/living/simple_animal/fox/init_belly() +/mob/living/simple_animal/fox/init_vore() ..() var/obj/belly/B = vore_selected B.name = "Stomach" @@ -187,7 +187,7 @@ tt_desc = "Vulpes nobilis" befriend_job = "Colony Director" -/mob/living/simple_animal/fox/fluff/Renault/init_belly() +/mob/living/simple_animal/fox/fluff/Renault/init_vore() ..() var/obj/belly/B = vore_selected B.name = "Stomach" diff --git a/code/modules/mob/living/simple_animal/simple_animal_vr.dm b/code/modules/mob/living/simple_animal/simple_animal_vr.dm index 58966051863..90d899fa08c 100644 --- a/code/modules/mob/living/simple_animal/simple_animal_vr.dm +++ b/code/modules/mob/living/simple_animal/simple_animal_vr.dm @@ -26,13 +26,6 @@ var/vore_fullness = 0 // How "full" the belly is (controls icons) var/vore_icons = 0 // Bitfield for which fields we have vore icons for. -/mob/living/simple_animal/New() - ..() - if(vore_active) - init_belly() - if(!IsAdvancedToolUser()) - verbs |= /mob/living/simple_animal/proc/animal_nom - // Release belly contents before being gc'd! /mob/living/simple_animal/Destroy() release_vore_contents() @@ -116,8 +109,6 @@ // TODO - Review this. Could be some issues here /mob/living/simple_animal/proc/EatTarget() ai_log("vr/EatTarget() [target_mob]",2) - if(!LAZYLEN(vore_organs)) - init_belly() stop_automated_movement = 1 var/old_target = target_mob handle_stance(STANCE_BUSY) @@ -138,13 +129,18 @@ release_vore_contents() . = ..() -// Simple animals have only one belly. This creates it (if it isn't already set up) -/mob/living/simple_animal/proc/init_belly() - if(vore_organs.len) - return - if(no_vore) //If it can't vore, let's not give it a stomach. +// Make sure you don't call ..() on this one, otherwise you duplicate work. +/mob/living/simple_animal/init_vore() + if(!vore_active || no_vore) return + if(!IsAdvancedToolUser()) + verbs |= /mob/living/simple_animal/proc/animal_nom + + if(LAZYLEN(vore_organs)) + return + + //A much more detailed version of the default /living implementation var/obj/belly/B = new /obj/belly(src) vore_selected = B B.immutable = 1 diff --git a/code/modules/mob/living/simple_animal/vore/shadekin/shadekin.dm b/code/modules/mob/living/simple_animal/vore/shadekin/shadekin.dm index 73027e0a373..7ca02a003b7 100644 --- a/code/modules/mob/living/simple_animal/vore/shadekin/shadekin.dm +++ b/code/modules/mob/living/simple_animal/vore/shadekin/shadekin.dm @@ -124,10 +124,8 @@ qdel_null_list(shadekin_abilities) . = ..() -/mob/living/simple_animal/shadekin/init_belly() - if(vore_organs.len) - return - if(no_vore) //If it can't vore, let's not give it a stomach. +/mob/living/simple_animal/shadekin/init_vore() + if(LAZYLEN(vore_organs)) return var/obj/belly/B = new /obj/belly(src) diff --git a/code/modules/vore/eating/living_vr.dm b/code/modules/vore/eating/living_vr.dm index 5eeedd3ef54..f43b221c03c 100644 --- a/code/modules/vore/eating/living_vr.dm +++ b/code/modules/vore/eating/living_vr.dm @@ -34,30 +34,37 @@ M.verbs += /mob/living/proc/insidePanel //Tries to load prefs if a client is present otherwise gives freebie stomach - if(!M.vore_organs || !M.vore_organs.len) - spawn(20) //Wait a couple of seconds to make sure copy_to or whatever has gone - if(!M) return - - if(M.client && M.client.prefs_vr) - if(!M.copy_from_prefs_vr()) - to_chat(M,"ERROR: You seem to have saved VOREStation prefs, but they couldn't be loaded.") - return 0 - if(M.vore_organs && M.vore_organs.len) - M.vore_selected = M.vore_organs[1] - - if(!M.vore_organs || !M.vore_organs.len) - if(!M.vore_organs) - M.vore_organs = list() - var/obj/belly/B = new /obj/belly(M) - M.vore_selected = B - B.immutable = 1 - B.name = "Stomach" - B.desc = "It appears to be rather warm and wet. Makes sense, considering it's inside \the [M.name]." - B.can_taste = 1 + spawn(2 SECONDS) + M.init_vore() //Return 1 to hook-caller return 1 +/mob/living/proc/init_vore() + //Something else made organs, meanwhile. + if(LAZYLEN(vore_organs)) + return TRUE + + //We'll load our client's organs if we have one + if(client && client.prefs_vr) + if(!copy_from_prefs_vr()) + to_chat(src,"ERROR: You seem to have saved VOREStation prefs, but they couldn't be loaded.") + return FALSE + if(LAZYLEN(vore_organs)) + vore_selected = vore_organs[1] + return TRUE + + //Or, we can create a basic one for them + if(!LAZYLEN(vore_organs)) + LAZYINITLIST(vore_organs) + var/obj/belly/B = new /obj/belly(src) + vore_selected = B + B.immutable = 1 + B.name = "Stomach" + B.desc = "It appears to be rather warm and wet. Makes sense, considering it's inside \the [name]." + B.can_taste = 1 + return TRUE + // // Hide vore organs in contents //