Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random welcome fix 1637 #1645

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions bbs/multmail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,16 @@ void add_list(int *pnUserNumber, int *numu, int maxu, int allowdup) {
bout.nl();
bout.outstr("Already in list, not added.\r\n\n");
i = 0;
break;
}
if (i) {
pnUserNumber[(*numu)++] = i;
}
}
}
if (i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet these two can be collapsed somehow, also isn't this already in an "if (i)" block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in prior section of code, "i = 0" can make this next section not fire off.

pnUserNumber[(*numu)++] = i;
}
} else {
if (i) {
pnUserNumber[(*numu)++] = i;
}
}
}
}
Expand All @@ -291,7 +296,7 @@ void add_list(int *pnUserNumber, int *numu, int maxu, int allowdup) {
#define MAX_LIST 40

void slash_e() {
int user_number[MAX_LIST], numu, i;
int user_number[MAX_LIST]={}, numu, i;
char s[81],*sss;

mml_s = nullptr;
Expand All @@ -315,7 +320,7 @@ void slash_e() {
numu = 0;
do {
bout.nl(2);
bout.outstr("|#2Multi-Mail: A,M,D,L,E,Q,? : ");
bout.print("|#2Multi-Mail: List: {} : A,M,D,L,E,Q,? : ",numu);
switch (char ch = onek("QAMDEL?"); ch) {
case '?':
bout.printfile(MMAIL_NOEXT);
Expand All @@ -325,9 +330,11 @@ void slash_e() {
break;
case 'A':
bout.nl();
bout.outstr("Enter names/numbers for users, one per line, max 20.\r\n\n");
bout.print("Enter names/numbers for users, one per line, max {}.\r\n\n",MAX_LIST);
mml_s = nullptr;
add_list(user_number, &numu, MAX_LIST, so());
//add_list(user_number, &numu, MAX_LIST, so());
add_list(user_number, &numu, MAX_LIST, 0); // do we really want sysops
// to be able to add dupe entries?
break;
case 'M': {
FindFiles ff(FilePath(a()->config()->datadir(), "*.mml"), FindFiles::FindFilesType::any);
Expand All @@ -351,7 +358,6 @@ void slash_e() {
bout.nl();
bout.outstr("|#2Which? ");
bin.input(s, 8);

File fileMailList(FilePath(a()->config()->datadir(), s));
if (!fileMailList.Open(File::modeBinary | File::modeReadOnly)) {
bout.nl();
Expand Down Expand Up @@ -383,6 +389,12 @@ void slash_e() {
break;
case 'D':
if (numu) {
bout.nl();
for (i = 0; i < numu; i++) {
User user;
a()->users()->readuser(&user, user_number[i]);
bout.print("{}. {}\r\n", i + 1, a()->names()->UserName(user_number[i]));
}
bout.nl();
bout.outstr("|#2Delete which? ");
bin.input(s, 2);
Expand All @@ -396,6 +408,7 @@ void slash_e() {
}
break;
case 'L':
bout.nl();
for (i = 0; i < numu; i++) {
User user;
a()->users()->readuser(&user, user_number[i]);
Expand Down
1 change: 0 additions & 1 deletion common/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "common/context.h"
#include "common/remote_io.h"
#include <chrono>
#include <cstdint>
#include <functional>
#include <set>
#include <string>
Expand Down
5 changes: 3 additions & 2 deletions common/printfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ void Output::print_local_file(const std::string& data) {

bool Output::printfile_random(const std::string& data) {
const printfile_opts opts(sess(), *this, data, true, true);
const auto& dir = sess().dirs().current_menu_gfiles_directory();
// const auto& dir = sess().dirs().current_menu_gfiles_directory();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what will this break?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can nix this. currently printfile_random and printfile default to using gfiles/menus/wwiv/gfiles/, which permits multiple menu configs. i was simplifying to just use gfiles/ directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think the right behavior here is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the current_menu_gfiles_directory() first if the file exists there, then check gfiles directory... i'll rework this.

const auto& dir = sess().dirs().gfiles_directory();
const auto base_fn = opts.data();
if (const auto dot_zero = FilePath(dir, StrCat(base_fn, ".0")); !File::Exists(dot_zero)) {
return false;
Expand All @@ -269,7 +270,7 @@ bool Output::printfile_random(const std::string& data) {
break;
}
}
return printfile_path(FilePath(dir, StrCat(base_fn, ".", os::random_number(screens))),
return printfile_path(FilePath(dir, StrCat(base_fn, ".", os::random_number(screens-1))),
opts.abortable, opts.force_pause);
}

Expand Down
1 change: 0 additions & 1 deletion sdk/ansi/makeansi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
/**************************************************************************/
#include "sdk/ansi/makeansi.h"

#include <cstdint>
#include <string>
#include <vector>

Expand Down
14 changes: 9 additions & 5 deletions sdk/ansi/makeansi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
/* either express or implied. See the License for the specific */
/* language governing permissions and limitations under the License. */
/**************************************************************************/
#ifndef INCLUDED_SDK_MAKEANSI_H
#define INCLUDED_SDK_MAKEANSI_H
#ifndef __INCLUDED_SDK_MAKEANSI_H__
#define __INCLUDED_SDK_MAKEANSI_H__

#include <string>

namespace wwiv::sdk::ansi {
namespace wwiv {
namespace sdk {
namespace ansi {

/**
* Passed to this function is a one-byte attribute as defined for IBM type
Expand All @@ -29,6 +31,8 @@ namespace wwiv::sdk::ansi {
*/
std::string makeansi(int attr, int current_attr);

} // namespace wwiv::sdk::ansi
} // namespace ansi
} // namespace sdk
} // namespace wwiv

#endif // INCLUDED_SDK_MAKEANSI_H
#endif // __INCLUDED_SDK_MAKEANSI_H__