#1: To get item ids that end in 0 (not equipment generally...)
itemID = itemID / 10 * 10;
#2: To get item ids that end in 5 (normal quality for equipment... non damaged non special versions)
if(itemID % 10 < 5)
itemID += 5 - newID % 10;
What this says in english (although I know you know what it does) is....
Take my id, divide it by 10 (gives me the LAST digit) and check if it's less than 5 (damaged or 'less than normal')
Now boost the ID by 5 - whatever it currently is (think about it... 1005 + 5-5 = 1005.... 1004 +5 - 4 = 1005. Simple logic)
Now you have to deal with other situations which are more likely
#3: You want to 'downgrade' all id's to a normal ID (IE: getting the base of a weapon maybe?)
itemID = itemID / 10 * 10 + 5;
That's the simplest way I can think of it. Just sets the last digit to 5 in this case (or whatever you want it to be really... set it to super if you wanted.
</sleepy post that probably completely bypasses the point of the thread>
I have tried split with \n and check if the current char was alpha only, but it still does it :/
Environment.NewLine:
Code:
/*===================================NewLine====================================
**Action: A property which returns the appropriate newline string for the given
** platform.
**Returns: \r\n on Win32.
**Arguments: None.
**Exceptions: None.
==============================================================================*/
public static String NewLine {
get {
Contract.Ensures(Contract.Result<String>() != null);
#if !PLATFORM_UNIX
return "\r\n";
#else
return "\n";
#endif // !PLATFORM_UNIX
}
}
Quote:
Originally Posted by BaussHacker
And this is how I get the item id:
Code:
for (int i = 0; i < Values.Length; i++)
{
if (Values[i].StartsWith("["))
{
ItemIDs.Add((Values[i] + 1).Replace("[Item", "").Replace("]", ""));
}
}
You could use Substring:
Code:
var lines = new[] { "[ItemDefault]", "[Item50000]", "[Item3111000]" };
foreach (var line in lines)
{
var sub = line.Substring(5, line.Length - 6);
Console.WriteLine(sub);
}
#1: To get item ids that end in 0 (not equipment generally...)
itemID = itemID / 10 * 10;
#2: To get item ids that end in 5 (normal quality for equipment... non damaged non special versions)
if(itemID % 10 < 5)
itemID += 5 - newID % 10;
What this says in english (although I know you know what it does) is....
Take my id, divide it by 10 (gives me the LAST digit) and check if it's less than 5 (damaged or 'less than normal')
Now boost the ID by 5 - whatever it currently is (think about it... 1005 + 5-5 = 1005.... 1004 +5 - 4 = 1005. Simple logic)
Now you have to deal with other situations which are more likely
#3: You want to 'downgrade' all id's to a normal ID (IE: getting the base of a weapon maybe?)
itemID = itemID / 10 * 10 + 5;
That's the simplest way I can think of it. Just sets the last digit to 5 in this case (or whatever you want it to be really... set it to super if you wanted.
</sleepy post that probably completely bypasses the point of the thread>
Well either way, my advice would be to ditch your "Values = sr.ReadToEnd().Split('\n');" and instead go with:
Code:
while ((CurrentLine = Reader.ReadLine()) != null)
And then for every line perform your filtering to get item ids and add them to the list.
For example, this is how i handle .ani files in my .wdf extractor, i realise that its not identical to what your trying to do, but you could do something similar certainly.
Code:
foreach (string _File in Directory.GetFiles(ConquerFolder + "\\ani"))
{
FileStream InputFile = new FileStream(_File, FileMode.Open);
TextReader Reader = new StreamReader(InputFile);
string CurrentLine = string.Empty;
string Path = string.Empty;
uint Key = 0;
while ((CurrentLine = Reader.ReadLine()) != null)
{
if (!CurrentLine.StartsWith("Frame") || CurrentLine.StartsWith("FrameAmount"))
continue;
string[] Data = CurrentLine.Split('=');
if (Data.Length < 2)
continue;
Path = Data[1];
Key = Shared.CalculateStringHash(Path);
if (!_HashList.ContainsKey(Key))
_HashList.Add(Key, Path);
}
}
Need String 08/20/2011 - Rappelz - 7 Replies Hi, I wanted to ask if there was a command to Auto-restart the server after the crash.
[VB08]String in String mit mehreren Funden 08/08/2011 - .NET Languages - 6 Replies Hey,
bin gerade auf ein Problem gestoßen, an dem ich mir seit 3 Stunden die Zähne ausbeiße.
Ich will eine Funktion schreiben, die der _StringBetween Funktion von AutoIt gleich ist. _StringBetween gibt in einem Array alle Strings zwischen zwei SubStrings und dem ganzen String aus. Die Ausgabe bei
_StringBetween("<h1>test1</h1>&l t;h1>test2</h1>", "<h1>", "</h1>") wäre also idealer Weiße ein Array (x = "test1", x = "test2")...
da man in VB08 kein Array returnen kann, komme ich aber einfach...
[C++] string zwischen string 11/11/2010 - C/C++ - 6 Replies tag gibts direkt ne funktion, mit der man einen passenden string zwischen dem string suchen kann?
also meine net .find() sondern sowas ähnliches, die in diesem beispiel "mein string sucht"
Bsp:
"<span id=\"lalala\">"+string mein_string+"</span>"
understanden? :-)
String.au3 09/11/2010 - AutoIt - 2 Replies Hey,
hat jemand die Datei für mich?
Ich finde im Internet nichts (ich hoffe ich habe nichts übersehn)
Mfg
[C++]Dev C++ string to int 08/06/2010 - C/C++ - 25 Replies Schonwieder ich :P
Also ich versuchs ma gut zu beschreiben.
Ich habe nen string in dem steht 1 und bevor einer fragt warum ich nicht direkt int benutzte es würde dan nicht funktioniern.
Also ich möchte den string in dem 1 steht in eine int variable umwandeln und danach irgendwan wieder zurück wie schaffe ich das? mit atoi habe ich es nicht hingekriegt und auch nicht mit strtoint