Joyce Posted June 25, 2010 Author Share Posted June 25, 2010 Well, I've been doodling around with the code below, but it either crashes on some NPCs for some reason with a subscript out of range(because a value is a string with " and more spaces, trimming them out has no effect), and when it does work the NPCs that don't even have any quest relations sometimes get marks as well, and the ones that need to have marks don't? I bet I did something wrong somewhere, but I really can't figure out what. :S```Public Sub BltQuestMarkers() Dim rec As DxVBLib.RECT Dim i As Long Dim n As Long Dim X As Long Dim NewQuests As Long Dim Data() As String Dim maxdata As Long If DDS_QuestMarker Is Nothing Then Call InitDDSurf("Quest", DDSD_QuestMarker, DDS_QuestMarker) End If rec.top = 0 rec.Left = 0 rec.Bottom = 32 rec.Right = 32 For i = 1 To MAX_MAP_NPCS If MapNpc(i).Num = 0 Then Exit Sub If Trim(Npc(MapNpc(i).Num).QuestRelation) <> "" Then Data = Split(Trim(Npc(MapNpc(i).Num).QuestRelation), ",") maxdata = UBound(Data()) NewQuests = 0 For n = 0 To maxdata If Trim(Data(n)) <> "0" Then For X = 1 To QUEST_MAXLOG If Trim(Data(n)) <> "" Then If Questlog(MyIndex).QuestComplete(Val(Data(n))) = 0 Then NewQuests = NewQuests + 1 End If End If Next X End If Next n End If If NewQuests > 0 Then Call Engine_BltFast(ConvertMapX(MapNpc(i).X * PIC_X), ConvertMapY((MapNpc(i).Y * PIC_Y) - 64), DDS_QuestMarker, rec, DDBLTFAST_WAIT Or DDBLTFAST_SRCCOLORKEY) End If Next iEnd Sub``` Link to comment Share on other sites More sharing options...
Robin Posted June 25, 2010 Share Posted June 25, 2010 Which line errors? Link to comment Share on other sites More sharing options...
Joyce Posted June 25, 2010 Author Share Posted June 25, 2010 It doesn't simply just error, it sometimes also simply renders the bugger on NPCs with no quests at all, for example enemies, or it doesn't render over the NPC it should render on.. But anyways, if it does error it errors on```If Questlog(MyIndex).QuestComplete(Val(Data(n))) = 0 Then```And Data(n) then equals " and it says Subscript out of range.. Trimming it doesn't work :S Link to comment Share on other sites More sharing options...
Robin Posted June 25, 2010 Share Posted June 25, 2010 Nothing wrong with your rendering code, your data is fucked.Make sure your packets are built properly. Link to comment Share on other sites More sharing options...
Kimimaru Posted June 25, 2010 Share Posted June 25, 2010 Everything looks good, but I've spotted out a few things that could use some improving, and maybe they will solve your problem. First, try using Trim$ instead of Trim. Second, use vbNullString instead of open quotation marks ("") to cut down on wasting a few bytes of memory. Also, check out this line:```maxdata = UBound(Data())```I don't think this will make a difference, but I usually UBound my arrays without the **()**, so try that. Link to comment Share on other sites More sharing options...
Robin Posted June 25, 2010 Share Posted June 25, 2010 None of those make any difference at all, Kim. They're just good practise.UBound should use parenthesis.The rendering code is fine, the problem lies in the data storage. Link to comment Share on other sites More sharing options...
Joyce Posted June 25, 2010 Author Share Posted June 25, 2010 Thing is I don't get where it'd mess up in the data storage :S Link to comment Share on other sites More sharing options...
Robin Posted June 25, 2010 Share Posted June 25, 2010 @Yami:> Thing is I don't get where it'd mess up in the data storage :SCheck your I/O packets and make sure they're all in the same order and you're writing a long when you're reading a long, etc. Link to comment Share on other sites More sharing options...
Joyce Posted June 25, 2010 Author Share Posted June 25, 2010 Fixed it with some help.. But he asked me not to mention him so I won't. ;DAnyways, here's the result..![](http://www.freemmorpgmaker.com/files/imagehost/pics/497d00c96c5169ff02176b63353291e5.png)Note that the sub has changed as well, on map load it parses the data of which NPCs to render them marks for, and then it'll use that data to blt them, rather then parsing it every frame. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now