|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
Archive::Development Archive area for Development's posts that were moved here after an inactivity period of 90 days. |
 |
|
 |

05-05-2002, 01:21 PM
|
Discordant
|
|
Join Date: May 2002
Posts: 434
|
|
Spell scribing - Code snippets
Code snippets complete, with a radix sort =)
A command to scribe all spells for someone would be useful.
There are serveral ways to go about this, one would to be on #scribespells <level>.. search all spells, if they are <= level and the character level, add them to the spellbook in the first availible space. Another way would be to do that, sort that list by level (assend or desend), maybe by basic type(icon) or by affects..
Level 1 Pet L1 Buff L1 Nuke L2 Nuke L2 Buff L3 Buff L3 Pet
L1 Pet L3 Pet L1 Buff L2 Buff L3 Buff L1 Nuke L2 Nuke
all would be pretty simple to implement, but would require O(n), assuming 5000 spells, thats 5000 + (sorting)
Another way if on load, create spell lists for each class, have them arranged by level and class and maybe type then when someone requested the spells, you would use a lot less O, and if more than one person did this, the saving would be tremendous.
So far, the precreated lists are the most appropriate and should be relatively easy to make. However, not having experience with the general code it is quite hard. If anyone needs help with the coding of the searching, sorting, I can help and will be working on it, but I would not be able to merge it easily.
ed. Need to do a better sort and get rid of index operator
|
 |
|
 |
 |
|
 |

05-07-2002, 02:08 AM
|
Discordant
|
|
Join Date: May 2002
Posts: 434
|
|
Code
Code:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct SPLtemp {
int spelllevel =0;
int splid =0;
}
void LoadSPDat() {
FILE *fp;
FILE SPlist;
for (int j = 0; j < SPDAT_RECORDS; j++)
memset((char*) &spells[j], 0, sizeof(SPDat_Spell_Struct));
if (fp = fopen(SPDat_Location, "rb"))
{
// if (_filelength(fp) != SPDAT_SIZE) {
// cout << "SPDat wrong size ('" << SPDat_Location << "'), spells not loaded." << endl;
// }
// else
{
for (int i = 0; i < SPDAT_RECORDS; i++) {
fread(&spells[i], sizeof(SPDat_Spell_Struct), 1, fp);
}
for (int x = 0;, x < 15; x++) {
SPlist.open(strcat(iota(x),".spl"),w);
SPLtemp tempsing;
tempsing.level =0; tempsing.splid=0;
vector<SPLtemp> buckets[7][10];
//LinkedList<LinkedList<SPLtemp>> buckets;
//LinkedList<SPLtemp> templist;
int spllen =0;
for (int i = 0; i < SPDAT_RECORDS; i++) {
if ( spells[i].classes[x] <= 60 ) {
tempsing.level = spells[i].classes[x]; tempsing.splid = i;
buckets[((spells[i].classes[x])/10)][(spells[i].classes[x])%10).push_back(tempsing);
spllen++;
}
}
/*int swap =0;
do {
for (int i = 0; i < spllen - 1; i++) {
if( templist[i].level > templist[i+1].level) {
tempsing = templist[i];
templist[i] = templist[i+1];
templist[i+1]=tempsing;
swap = 1;
}
}while(swap !=0);*/
/*for (int i =0; i < spllen; i++) {
SPlist >> templist[i].level >> ' ' >> templist[i].splid;
{
*/
for(int x =0; x < 7; x++)
{
for(int y =0; y < 10; y++)
{
int count = 0;
while(count > buckets[x][y].size)
{
SPlist >> buckets[x][y][count].level >> ' ' >> buckets[x][y][count].splid;
count++
};
}
SPlist.close();
{
spells_loaded = true;
cout << "Spells loaded from '" << SPDat_Location << "'." << endl;
}
fclose(fp);
}
else
cout << "SPDat not found ('" << SPDat_Location << "'), spells not loaded." << endl;
}
That should parse the file and create 15 spell lists, in 1.spl = 15.spl with the format
level spellid
Now, client.cpp
Code:
client.cpp
if ((strcasecmp(sep.arg[0], "#scribespells") == 0))
{
if (target == 0) {
Message(0, "Error: #scribespells: No target");
}
else if (sep.arg[1][0] == 0) {
Message(0, "Usage: #scribespells x");
}
else {
int16 level = atoi(sep.arg[1]);
if (level > 0 && (level <= 60 {
FILE sp; sp.open(strcat(atoi(sep.arg[6]),".spl); int templvl = 0;int tempid=0; int y =1;
sp >> templvl >> tempid;
while(templvl >= level)
{
pp. spell_book[y]=tempid;
sp >>templvl >>tempid; y++;
};
else {
Message(0, "Error: #scribespells: Invalid Level");
}
}
}
|
 |
|
 |

05-22-2002, 11:39 AM
|
Discordant
|
|
Join Date: May 2002
Posts: 434
|
|
TTT
|

05-22-2002, 04:59 PM
|
Fire Beetle
|
|
Join Date: Jan 2002
Posts: 11
|
|
Good idea!
|

05-27-2002, 05:32 AM
|
Fire Beetle
|
|
Join Date: May 2002
Posts: 4
|
|
this will never compile on a linux machine :p
|

05-27-2002, 09:28 AM
|
 |
Dragon
|
|
Join Date: Jan 2002
Posts: 708
|
|
bahaha you obey my commands! 
|

05-27-2002, 10:29 AM
|
Discordant
|
|
Join Date: May 2002
Posts: 434
|
|
ANSI (new) headers work in linux
That will compile, by it self, but the new hearders will kill most of the other code, working on fixing linked_list.h (posted without compiling in the codebase, heh.. oops)
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 01:45 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |