Seifert69 / DikuMUD3

DikuMUD III using HTML and websockets.
GNU Lesser General Public License v2.1
192 stars 48 forks source link

Refactor external functions to members of unit_data #347

Closed bluedreamer closed 2 years ago

bluedreamer commented 2 years ago

A lot of standalone functions can now be member functions of unit_data

Seifert69 commented 2 years ago

Further to my comment about " ".

I did a grep in the code and can see that you just copied it as was. But that we also use it differently in some other places.

db_file.cpp:                     (((dilprg *)fptr->getData())->fp->tmpl->prgname ? ((dilprg *)fptr->getData())->fp->tmpl->prgname : "NO NAME"),
db_file.cpp:                     (((dilprg *)fptr->getData())->fp->tmpl->prgname ? ((dilprg *)fptr->getData())->fp->tmpl->prgname : "NO NAME"),
grep: defcomp: Is a directory
event.cpp:                strcpy(dilname, "NO NAME");
event.cpp:                strcpy(diloname, "NO NAME");
event.cpp:                    strcpy(diloname, tmp_event->arg1 ? UNIT_FI_NAME((unit_data *)(tmp_event->arg1)) : "NO NAM
");
grep: mplex: Is a directory
grep: pp: Is a directory
utils.h:inline const char *UNIT_FI_NAME(const unit_data *unit) { return unit->getFileIndex() ? FI_NAME(unit->getFileIndex()) : "NO-NAME"; }
Seifert69 commented 2 years ago

(and can see some of them are file dilprg names, and in one place it looks like dead code file fileIndexNames)

Seifert69 commented 2 years ago

Exactly. I did make a SymName in DIL six months ago. It's been on my to-do :-D

On Wed, Jun 29, 2022 at 8:16 AM Adrian @.***> wrote:

@.**** commented on this pull request.

In vme/src/event.cpp https://github.com/Seifert69/DikuMUD3/pull/347#discussion_r910095026:

@@ -287,8 +285,8 @@ void eventqueue::process() { strcpy(dilzname, prg->fp->tmpl->zone->getName()); }

  • strcpy(diloname, tmp_event->arg1 ? UNIT_FI_NAME((unit_data *)(tmp_event->arg1)) : "NO NAME");
  • strcpy(dilozname, tmp_event->arg1 ? UNIT_FI_ZONENAME((unit_data *)(tmp_event->arg1)) : "NO ZONE");
  • strcpy(diloname, u ? u->getFileIndexName() : "NO NAME");

Cool - I'll do that next. I want to create a function too that returns the full name - save all those double calls like this in_str = diku::format_to_str("%s@%s", u->getFileIndexName(), u->getFileIndexZoneName());

I didn't do it yet to make the change easier to review

— Reply to this email directly, view it on GitHub https://github.com/Seifert69/DikuMUD3/pull/347#discussion_r910095026, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOOOMXVYGQEB746BYQYYRELVRRSEBANCNFSM52FQCCMQ . You are receiving this because you commented.Message ID: @.***>