Friday, September 25, 2009

Vector upgrade

I have fixed some bugs, add a lot stuff and there it is - new version of vector module.



You can see it all here:
auxilary.h
vector.h
vector.c
main.c

How could one use it?

Of course you can mix these approaches to get what you exactly want to.

What's more?
  • search for and counts occurences of element in vector
  • compare vectors
  • concatenate and insert one vector to another
  • get part of vector as a new vector
Case study?
A friend of mine asked if vector could prevent such errors he can ocassionally see:
for ( af = ch->affected; af != NULL; af = af->next )
{
  if ( af->bitvector == &AFF_PARALYZE )
  {
    affect_strip(ch,af->type);
    if (!IS_NPC( ch ) )
    send_to_char( "Z powodu bólu, odzyskujesz kontrolę nad swoim ciałem\n\r", ch );
  }
}

affect-strip removes one or more nodes from af list which can cause crash or something unpredictable.

What such situation could look like when using vector? I hope he will be able to answer to this question himself. :)

No comments:

Post a Comment