skigoggles 0 Posted December 21, 2015 Has anyone else really stepped through this code? A while ago I did and made a note that it always got an error and wasn't working. I know on the server I run there were items in the debug that were not getting deleted. I went back to it recently and started debugging/logging what it was doing. The splitting of the worldspace column is one of those crazy lines of code, IMO:SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 2), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 1), ',', '') INTO @West;SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 3), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 3 -1)) + 1), ',', '') INTO @North; but when I researched it, it's basically the same as found here: http://stackoverflow.com/questions/11835155/mysql-split-comma-separated-string-into-temp-tableWhen I run through each step on paper it seems to be correct. Finally, after debugging for a while I'm seeing that the @West value is generally not being set correctly so I created a log file and added this to pCleanupOOB() - just decomposed pieces of the code above. The bold/italic/underline text are the values from my log file: insert into aalog values (@rsObjectUID, 130279766221295@rsWorldspace, 60,13027.9,7662.17,-0.01SUBSTRING_INDEX(@rsWorldspace, ',', 2), 60,13027.9SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1), 60LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 1, 3SUBSTRING_INDEX(@rsWorldspace, ',', 2), 60,13027.9SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 2), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 1), ,13027.9@West, 13027@North, 7662.17@Height); -0.01 Like I said it looked good on paper, but when its decomposing the worlspace, the @West variable string thats extracted includes the leading comma, so the number doesn't always get converted properly. The solution seems to be : from this>> LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 1to this:>> LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 2 now, I was a software developer for years, so I like it when a good "+1" just fixes it, but I'd like to hear from someone else that's noticed this. Has anyone else seen this code cleanup OOB items? If you'd like to see for yourself, here's some the code. You'll see I added @Height to pickup the Z value since I wanted to look for helis left on buildings. Also, I have 2 inserts into the log file - the first with the original values and the second with the +1.CREATE TABLE `aalog` ( `id` BIGINT(20) NOT NULL, `ws` VARCHAR(50) NULL DEFAULT NULL, `str1` VARCHAR(50) NULL DEFAULT NULL, `str2` VARCHAR(50) NULL DEFAULT NULL, `int1` INT(11) NULL DEFAULT NULL, `str3` VARCHAR(50) NULL DEFAULT NULL, `str4` VARCHAR(50) NULL DEFAULT NULL, `x` FLOAT NULL DEFAULT NULL, `y` FLOAT NULL DEFAULT NULL, `z` FLOAT NULL DEFAULT NULL)COLLATE='latin1_swedish_ci'ENGINE=InnoDB; CREATE DEFINER=`dayz`@`%` PROCEDURE `pCleanupOOB`() LANGUAGE SQL NOT DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER COMMENT ''BEGIN DECLARE intLineCount INT DEFAULT 0; DECLARE intDummyCount INT DEFAULT 0; DECLARE intDoLine INT DEFAULT 0; DECLARE intWest INT DEFAULT 0; DECLARE intNorth INT DEFAULT 0; DECLARE dblWest FLOAT DEFAULT 0; DECLARE dblNorth FLOAT DEFAULT 0; DECLARE dblHeight FLOAT DEFAULT 0; SELECT COUNT(*) INTO intLineCount FROM Object_DATA; SELECT COUNT(*) INTO intDummyCount FROM Object_DATA WHERE Classname = 'dummy'; WHILE (intLineCount > intDummyCount) DO SET intDoLine = intLineCount - 1; SELECT ObjectUID, Worldspace INTO @rsObjectUID, @rsWorldspace FROM Object_DATA LIMIT intDoLine, 1; SELECT REPLACE(@rsWorldspace, '[', '') INTO @rsWorldspace; SELECT REPLACE(@rsWorldspace, ']', '') INTO @rsWorldspace; SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 2), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 1), ',', '') INTO @West; SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 3), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 3 -1)) + 1), ',', '') INTO @North; SELECT REPLACE(SUBSTRING(@rsWorldspace, LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 3))+1 ) , ',', '') INTO @Height; SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 2), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 2), ',', '') INTO dblWest; SELECT REPLACE(SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 3), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 3 -1)) + 2), ',', '') INTO dblNorth; SELECT REPLACE(SUBSTRING(@rsWorldspace, LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 3))+1 ) , ',', '') INTO dblHeight; SELECT INSTR(@West, '-') INTO intWest; SELECT INSTR(@North, '-') INTO intNorth; insert into aalog values (@rsObjectUID, @rsWorldspace, SUBSTRING_INDEX(@rsWorldspace, ',', 2), SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 1, SUBSTRING_INDEX(@rsWorldspace, ',', 2), SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 2), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 1), @West, @North, @Height); insert into aalog values (@rsObjectUID, @rsWorldspace, SUBSTRING_INDEX(@rsWorldspace, ',', 2), SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 2, SUBSTRING_INDEX(@rsWorldspace, ',', 2), SUBSTRING(SUBSTRING_INDEX(@rsWorldspace, ',', 2), LENGTH(SUBSTRING_INDEX(@rsWorldspace, ',', 2 -1)) + 2), dblWest, dblNorth, dblHeight); IF (intNorth = 0) THEN SELECT CONVERT(@North, DECIMAL(16,8)) INTO intNorth; END IF; IF (intWest > 0 OR intNorth > 15360) THEN DELETE FROM Object_DATA WHERE ObjectUID = @rsObjectUID; END IF; SET intLineCount = intLineCount - 1; END WHILE;END Share this post Link to post Share on other sites
vinyljunkie 165 Posted December 21, 2015 Hey, there is a github for stuffz like this: https://github.com/DayZMod/DayZ/issues Maybe you can contribute. Also join the discord. Cheers. Share this post Link to post Share on other sites
skigoggles 0 Posted December 22, 2015 (edited) Hey, there is a github for stuffz like this: https://github.com/DayZMod/DayZ/issues Maybe you can contribute. Also join the discord. Cheers.You are right - https://github.com/DayZMod/DayZ/issues/601 - pCleanupOOB() not parsing worldspace correctly #601 I'll find you on the discord when I get a chance. thanks. Edited December 22, 2015 by skigoggles Share this post Link to post Share on other sites